Installing Dependencies
First, we’ll need to install NGINX. Update apt and install it:
If you have a firewall enabled, like UFW, you’ll need to open it up:
We’ll configure NGINX once WordPress is installed. In the meantime, we’ll need to create a MySQL database for WordPress to use.
If you don’t have MySQL installed, you can get it from apt. Make sure to run mysql_secure_installation once it’s installed to lock it down. You can read our guide on general database security for more info, but as long as MySQL is running on localhost, you should be fine.
Create a database for WordPress to use. You don’t need to set up tables or anything, just a blank database will do:
Then create a user, called wordpressuser, and give it access to the database. Make sure to change the password.
WordPress runs on PHP, so it’ll need PHP installed to function. Install it alongside the following extensions:
And restart the PHP service to make sure it’s up to date with the new extensions. Note that you may need to change the version number here.
Installing WordPress
Download the latest build of WordPress from their site:
Then copy the sample configuration to the location WordPress actually reads from:
Move the temp directory to the proper install location, and chown the data:
You’ll need to set the salts that are used for security and password management. You can fetch a new set of salts from WordPress’s API:
Then, open up WordPress’s config file, and paste the values in:
While you’re in this file, you’ll need to configure the database settings.
Once that’s done, WordPress should be configured, and we’ll need to configure NGINX to serve the content.
Configuring NGINX
NGINX uses config files in /etc/nginx/sites-available/ to configure different endpoints. Create a new one for your site in this folder, and paste in the following:
Note that you will need to put in your info for the hostname and other settings, as well as updating the PHP version if you are using a newer one. You will need to save this in sites-available, then symlink it to sites-enabled to turn it on.
Once it’s enabled, restart NGINX, and you’ll see WordPress if you visit the site in your browser. You’ll need to do the first time setup walkthrough.
You’ll now be able to view your dashboard at any time at https://example.com/wp-admin/.
Next, you’ll need to configure SSL to secure connections on your site. You can do this for free using certbot, a CLI frontend to LetsEncrypt’s free certificates.
Then, run certbot:
After that, you will need to restart NGINX.
sudo service nginx restart
Setting Up Your Site
Congratulations! You have a running WordPress site. It probably looks terrible with the default theme. The first thing you’ll want to do is change the theme, which you can do from the dashboard:
Whatever theme you choose, you’ll need to activate it from the appearance tab.
Then, you can configure the settings and style by visiting the site and clicking “Customize” in the header. One of the best things you can do is add completely custom CSS to the site, which can change any element on the page.
If you want to edit something in the theme, and you don’t mind messing around in PHP, you can edit your theme files directly. For example, I edited my theme file to layout a grid with two posts side, rather than just a list of posts.