Install WordPress with LEMP Stack on Powerful Cloud Server

Learn to install WordPress in DigitalOcean Cloud using SSH and SFTP clients on Ubuntu Server with MySQL8.0, PHP7.3-FPM Processor, and Nginx Web Server.

WordPress is no doubt one of the best content management systems and blogging software. In this article, I’m going to share a step-by-step guide on how to install WordPress with LEMP Stack on a cloud server.

I recently published a few articles on how to create LEMP stack as well as how to login SSH and SFTP on Ubuntu Cloud Server. I’m using DigitalOcean Cloud server hosting. If you haven’t read those gone through the article, then recommend reading them to connect the dots.

I just wanted to share that this article and video demo is the part of #WordPressBlog Series. In this series of posts, I’m going to touch base upon some of the best guides on configuration, security, optimizing and install WordPress on Cloud Server.

Let’s dive into learning WordPress Installation with LEMP —

What is WordPress?

WordPress is a free and open-source content management system based on PHP & MySQL. Features include a plugin architecture and a template system. It is most associated with blogging but supports other types of web content including more traditional mailing lists and forums, media galleries, and online stores.

It’s also said that WordPress is powering almost 65% of all the websites available on the internet today. WordPress also supports building the forums with bbPress, and e-commerce site using Woocommerce.

As mentioned above, has plugin and template architecture called themes, which makes it #1 choice for developers as well as users.

WordPress also has a which helps to create under its subdomain at no cost. However, the customization available in is quite limited and restricted.

Setup Registrar DNS to Point Domain toward Server IP

Each Ubuntu cloud server is assigned with a dedicated IP address unique to each other. These address help to locate the server and files when someone requests via the web browser.

It’s quite difficult to remember this multi-digit numeric IP Address. Hence, the concept of domain name came into the picture.

An IP address can be assigned to multiple domain names, however, a single domain name can have a unique IP address. Whenever someone visits the domain via browser, its resolved into an assigned IP address and the files are retrieved from the webserver to a web browser.
Welcome to nginx! message on IP Address

In our case, we already have an IP Address allocated to our Ubuntu Cloud Server via DigitalOcean. All we need to do is assign a domain name to this IP Address.

The domain name can be further split into multiple sub-domains and one root domain. Example:

  • — is the root domain name whereas
  •;; are sub-domains

Each subdomain can be further associated with a unique IP Address. And I will be using to associate with our cloud server IP Address.

The below steps will help either to assign your root domain name or sub-domain name to the IP address. If you’re planning to completely install WordPress, then suggest going ahead with root domain association to IP.

If you do not have a domain name registered, then make a purchase at Google Domains or GoDaddy.

Follow the steps to assign the (Sub)Domain name to IP address:

  1. Login into your Domain registrar; say Google Domains
  2. Select the Domain name from the list
    Select Domain Name in Google Domains
  3. Open DNS Settings
    Open DNS Settings in Domain Registrar
  4. Add an A record pointing to your IP Address with default TTL value
    • If using root domain then add point to IP Address
    • If you’re using sub-domain then add point to server IP Address
    • In my case, I’ll be adding the sub-domain point to
      Adding A Type records in DNS Settings for point domain name to IP Address
  5. That’s it, your domain name is set up and associated with an IP Address now

The propagation of DNS settings might take anywhere from 5 mins to 24 hours and we do not have control. Meanwhile, you can progress with creating a MySQL Database for WordPress mentioned in the next section.
Once the DNS propagation is completed, visit your domain name in the browser to verify if the website is live.
DNS propagation completed - Domain is resolving to IP Address

You can also ping your domain name if it’s resolving your IP address.

Type ping in the macOS terminal or Windows OS CMD Prompt and check the IP Address.
Ping Domain Name in Windows CMD Prompt

I can see the Reply from IP Address is my Ubuntu Cloud Server IP Address. This confirms that my IP Address setup is completed.

Create MySQL Database and User for WordPress

Moving into MySQL Database —

WordPress needs a database server to store and retrieve the post and images published online. It also stores all the settings and meta information into a database server.

MySQL Server 8.0 is one the fastest server which we will be using for WordPress database management. You can learn how to install MySQL 8.0 on the LEMP Stack setup guide.

WordPress Configuration needs 3 information as a part of MySQL database setup.

  1. Database name: wpdatabase
  2. Database user: wpuser
  3. Database password: wppassword

We will be creating a new database and username along with the password for WordPress using these dummy values. Login cloud via an SSH client and run following commands to generate the

MySQL DB for WordPress:

Login into MySQL from SSH using root account:

mysql -u root -p

Enter the MySQL root account password when prompted.
Login into MySQL 8.0 on Ubuntu Cloud Server

Let’s create a database for WordPress. I’ll be using dummy values as mentioned above, however, you can modify as per wish.


Next, we are going to create a MySQL user with password and grant permissions to the database to operate and manage independently.

CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'wppassword';
GRANT ALL ON wpdatabase.* TO 'wpuser'@'localhost';

Now we have created a database and also granted a user with full permission. Commit the changes into MySQL server and exit using the following command:


This will flush all the privileges and commit the changes in MySQL.

Created Database and User for WordPress on MySQL

The MySQL session will be terminated, and you will be back into the Ubuntu shell.

Configuring Nginx for Domain and WordPress Setup

In the previous post, while setting up LEMP Stack we modified the Nginx Configuration default file located at /etc/nginx/sites-available/ to listen our IP Address and PHP Processor Socket.

This time we are going to adjust and add some additional value to the same configuration file.

  1. We are going to change the server_name from IP Address to the domain name; in my case
  2. Within the main server block, adjust the root to read the WordPress installation from /var/www/demo directory
  3. Inside the existing location / block, adjust the try_files to pass control to index.php file in WordPress, instead of default 404 errors by commenting it

So the final setup of default Nginx Configuration files after ignoring the commented lines will look like:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/demo;
    index index.php index.html index.htm index.nginx-debian.html;
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.3-fpm.sock;
    location ~ /\.ht {
        deny all;

Modified Nginx for reading WordPress files and folders

That’s it. Close the editor, commit the changes into Cloud Server. Test the Nginx using below command:

nginx -t

If the test configuration goes well, then finally restart nginx:

sudo service nginx restart

You’ve now completed the Nginx setup to listen to the WordPress installation directory and will be using WP for any 404 errors.

Download and Configure WordPress Files

Now that our server has configured. Let’s proceed with downloading WordPress into our server. It’s strongly recommended to download the latest version for security reasons.

cd /tmp
curl -LO

Extract the WordPress compressed file:

tar xzvf latest.tar.gz

Download and UnZip WordPress using SSH on Cloud Server

After extracting the WordPress in /tmp/ folder, let’s make the copy of wp-config-sample.php file to wp-config.php.

cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php

Now, we can copy the entire contents of the directory into our document root folder that we defined in the Nginx configuration file. Use below command:

sudo cp -a /tmp/wordpress/. /var/www/demo

Copy wp-config-sample.php file and entire WordPress into root directory

Now that we have moved the files in the correct directory, we need to assign the right ownership www-data user and group. This is the user and group that Nginx runs and needs to be able to read and write WordPress files in order to serve the website and perform automatic updates.

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

We have now moved the WordPress in the document root folder and assigned correct ownership.

Next, we need to secure the installation by adding secret key values and use the MySQL database details the wp-config.php file.

Open the WordPress configuration file in SFTP client FileZilla located in /var/www/demo/wp-config.php and follow the steps:
visit WordPress root directory via SFTP

Generate the secret key using WordPress secret key generator in SSH:

curl -s

You will get the unique values that need to replace dummy values already present in wp-config.php file.
generate and replace the salt secret values in WordPress

Next, we need to modify database value to reflect with our MySQL database details.

. . .
define('DB_NAME', 'wpdatabase');
/** MySQL database username */
define('DB_USER', 'wpuser');
/** MySQL database password */
define('DB_PASSWORD', 'wppassword');
. . .

Finally, allow WordPress to write to the file system by defining the FS_METHOD in the wp-config.php file by adding the following snippet:

define('FS_METHOD', 'direct');

FS_METHOD direct defined in WordPress wp-config.php file

Save the file, and upload it back to the SFTP server.

Finally, reboot the Ubuntu Server to commit all the changes made.


Install WordPress in Web Browser

We have successfully completed all the setup and configuration of Nginx, PHP, and MySQL to support WordPress installation.

In order to install WordPress, open the web browser and visit your domain name. For my installation, I will be visiting:

Select the preferred language from the list — I’ve selected English (United States).
Install WordPress - Language Selection

Continue next for the important setup page. Where you can enter the Site Title, Username, Password, Email ID and select Search Engine Visibility option.
Install WordPress - Account Details Setup

Finally hit on the Install WordPress button to complete the installation process successfully. Login to your fresh WordPress installation to see how it looks!
WordPress Dashboard - First Time Login after Installation

Video Demo to Install WordPress

Watch the complete demo on how to install WordPress with the LEMP stack on the Ubuntu server.

The video will be covering all the steps discussed in this article from creating the MySQL database to configuring the WordPress configuration file.

Install WordPress with LEMP Stack on Powerful Cloud Server

Hope you liked the video, please subscribe to the YouTube channel.

What’s Next in #WordPressBlog¬†Series?

In the next article, I will be sharing how to log in WordPress for the first time and configure the preliminary settings in detail.

If you've any thoughts on Install WordPress with LEMP Stack on Powerful Cloud Server, then feel free to drop in below comment box. If you find this article helpful, please consider sharing it with your network.

Also, please subscribe to our restoreBin YouTube channel for helpful videos.

Disclosure: This page may contain affiliate links, which means we may receive compensation for your purchases using our links; of course at no extra cost to you (indeed, you may get special discounts). This will support our effort to create more useful content, and keep it open and free forever.

Leave a Reply

Your email address will not be published. Required fields are marked *