Install WordPress on DigitalOcean with 1-Click
WordPress is a fantastic tool that has come a long way. You can use it to:
- Power your website
- Use as a Headless CMS via REST API
We’ll talk more on the uses of WordPress in other articles. For this article, we’ll focus on installing WordPress on DigitalOcean.
Installing WordPress on DigitalOcean
DigitalOcean has a Marketplace where there are applications that we can deploy with 1-click.
There are popular tools we can install quickly like WordPress, Ghost CMS, Strapi, Node, and more.
Using the WordPress DigitalOcean 1-Click
We can find the WordPress 1-click installation on the DigitalOcean Marketplace: marketplace.digitalocean.com/apps/wordpress
Upcoming Course: Make 20 React Apps!
The installation instructions on this page are good to read through. We’ll be following along with this and also bringing in our own screenshots for our walkthrough.
Let’s give the Create WordPress Droplet button a click. We are taken to our DigitalOcean dashboard where we can configure and create a new droplet.
Let’s keep the standard setup with the $40 droplet. You can change this based on your site traffic and needs. You could use a smaller droplet while getting your project off the ground and then resize it later.
Be sure to pick the location closest to your customers.
Another important part of the setup to focus on is the SSH keys. This is how you will login to your newly created droplet.
You’ll be taken back to your dashboard where you can see your new droplet being created!
Notice that I have a few domains sitting in my DigitalOcean account. A domain is required to setup the WordPress install.
What comes with this 1-Click DigitalOcean WordPress install?
This install does a few things out of the box for us. It’s convenient since we won’t have to install a lot of this ourselves:
- Enables the UFW firewall to allow only SSH (port
22
, rate limited), HTTP (port80
), and HTTPS (port443
) access. - Sets the MySQL root password, runs
mysql_secure_installation
, and creates awordpress
user with the necessary permissions. Note, the Droplet root user will not be prompted for the MySQL password. - Sets up the
debian-sys-maint
user in MySQL so the system’s init scripts for MySQL will work without requiring the MySQLroot
user password. - Creates the initial WordPress configuration file to set up salt keys and allow the WordPress instance to connect to the database.
- Disables XML-RPC to help prevent DDoS and other brute force attacks.
- Modifies some of PHP’s settings to increase the maximum filesize and execution time.
- Enables the Apache rewrite module so the WordPress permalink feature will work.
- Configures Apache with
UseCanonicalName On
to mitigate CVE-2017-8295.You need a fully qualified domain name (FQDN) to use this One-Click, which you can purchase from any domain registrar. You do not have to manage your domain with DigitalOcean DNS.
Setting Up WordPress
Now that our droplet is setup, we need to SSH into it so that we can finish our WordPress installation. Let’s SSH into our droplet:
ssh root@use_your_droplet_ip
Once we SSH into the droplet, we can start the setup:
A domain is the first thing required by our new WordPress setup. We can add a domain and then we will make sure that domain is pointed towards our new droplet. I’ve added one of my old domains here: angularmachine.com. We’ve also set up our:
- username
- password
- blog title
Make sure to run the following after all this is done so that the new setup will be loaded.
systemctl reload apache2
LetsEncrypt and Making WordPress HTTPS
Next up, we will be prompted to install LetsEncrypt and HTTPS for this domain.
The first thing we need to do is make sure that our domain is pointed at this new droplet. We’ll go back into our dashboard, under networking and create the following A records.
@ use_your_droplet_ip
www use_your_droplet_ip
Go back to your installation and let’s start the LetsEncrypt setup. Note that it may take a couple minutes for the DNS changes to take place. Go through the setup and tell LetsEncrypt that it will need to work for both the main domain and the www
domain.
We can make all site traffic be HTTPS:
We can now see our site is live!
You can login to your admin dashboard at https://your-site.com/wp-admin.
Conclusion
We have a WordPress install up and running quickly with DigitalOcean’s 1-click apps. You can now use this WordPress site as your main site or use it as a Headless CMS and pair it with a frontend tool like Gatsby.
No matter what you do with your site, you will always have control of the content and database since it is hosted on your own droplet.
Like this article?
Follow @chrisoncode on Twitter