How to install WordPress on Ubuntu 18.04 running Nginx on a Virtual Host Server with LetsEncrypt SSL.

WordPress runs much better on Nginx than Apache. This guide will show you how to easily install multiple WordPress instances on Ubuntu 18.04 running Nginx with a free LetsEncrypt SSL certificate. Presumable you have a LEMP installation already running.

Most of my websites use WordPress and I build a lot of them to either sell on Flippa or keep with the hope that one day they earn revenue. This page you are reading now is hosted on a virtual hosting server running Nginx on Ubuntu 18.04 along with around 20 other websites. I use DigitalOcean to host all of my websites and the guide below is exactly how I manage to do so.

The process is really simple. We create a virtual host instance, install LetsEncrypt, create a domain instance, point the domain to the server, add the SSL certificate, create a MySql database and install WordPress. Follow the step by step guide below and repeat for each instance of WordPress you wish to install per domain. Don’t forget to change “” to your own domain name!

Note: You must already be running a LEMP installation. LEMP already has PHP, MySql and Nginx installed as default.

1, Create a Virtual Host Instance

sudo mkdir -p /var/www/
sudo chown -R www-data: /var/www/

Now we create a server block. Simply run the command below and copy the code into the blank file replacing with your own domain name.


sudo nano /etc/nginx/sites-available/


server {
    listen 80;
    listen [::]:80;
    root /var/www/;
    index  index.php index.html index.htm;
     client_max_body_size 100M;
    location / {
        try_files $uri $uri/ /index.php?$args;
    location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;

Now run the following commands:

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
sudo systemctl restart nginx

2, Setup your Domain DNS

You need to setup an A and CName record. In this guide we will be using non www.

A Record = Hostname: > Value: Server IP > TTL: 3600

CName = Hostname: > Value: > TTL: 43200

Example below:

Domain A Record

Domain CName Record


3, Install LetsEncrypt SSL for the Domain

sudo add-apt-repository ppa:certbot/certbot
sudo apt install python-certbot-nginx
sudo ufw allow 'Nginx Full'
sudo systemctl reload nginx
sudo certbot --nginx -d YOURDOMAIN.COM

Select option 2:

2: Redirect - Make all requests redirect to secure HTTPS access.


4, Install ZIP UNZIP

sudo apt install zip


5, Download WordPress Files to your Server

Navigate to the public_html folder of your domain name:

cd /var/www/

Now grab the WordPress zip file using WGET:

sudo wget

Unzip the WordPress archive

sudo unzip

6, Create a MySQL Database

You will need your default database password for this step. If you are using DigitalOcean, run the following command to get the default MySQL password:

cat /root/.digitalocean_password

Now we create a database name, database user and database password using the commands below:

mysql -p
create database databasename;
grant all privileges on databasename.* to 'databaseusername'@'localhost' identified by "databasepassword";
flush privileges;

7, Install Additional PHP Extensions

sudo apt update
sudo apt install php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip
sudo systemctl restart php7.2-fpm


8, Redo File Permissions

sudo chown -R www-data: /var/www/


9, Install WordPress

Now the hard part is done, simply navigate to your domain name and follow the WordPress installation instructions. You will need your MySQL info from step 6.


That’s all there is to it! You should now have a fully working WordPress installation on your Ubuntu 18.04 virtual hosting server running on Nginx.

To add more WordPress websites, simply follow the guide and miss out the LetsEncrypt and PHP initial installations or just skip steps 3 and 7 using only the

sudo certbot --nginx -d YOURDOMAIN.COM

to install SSL onto your domain name.


You might want to also setup Postfix Email Forwarding using this simple guide here.


I use DigitalOcean for all my website hosting. You can get $100 free DigitalOcean credit by using my referral link here.