WordPress is one of the most popular content management systems (CMS) in the world. It’s free and easy to use, making it a great choice for small businesses and personal blogs. But what if you want to set up your own WordPress site? You can do that with Ubuntu and NGINX, two powerful web servers. In this article, we’ll show you how to set up a WordPress site on your own servers using Ubuntu and NGINX. First, you’ll need a server running Ubuntu or NGINX. We recommend using a server with at least 8GB of RAM and 1TB of storage space. You can find more information about choosing a server here: https://www.digitalocean.com/community/tutorials/how-to-choose-a-server Once you have your server set up, install Ubuntu or NGINX onto it. We recommend using the latest version of Ubuntu or NGINX available at the time of writing: 16.04 LTS or 18.04 LTS (Ubuntu), or Nginx 1.14 (NGINX). If you are using an older version of Ubuntu or NGINX, please see our instructions for upgrading below: Once Ubuntu or NGINX is installed, open a terminal window and type the following commands to create a new WordPress site: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ..
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.