Install WordPress on Ubuntu 17.10 with Nginx, MariaDB and PHP-FPM (LEMP)

This brief tutorial will show students and new users how to install WordPress on Ubuntu 17.10 with Nginx, MariaDB and PHP-FPM support. This tutorial should be easy to read and understand, even for new users who is just starting with installing WordPress.

WordPress is an open source software that anyone can use to create powerful and dynamic websites and apps. With the help of the LEMP stack, you can create beautiful and dynamic websites with many features. Many large and popular websites run WordPress.

If you’re new and you want to learn how to easily install WordPress on Ubuntu, this tutorial should help you get there.

We’re going to install WordPress on top of the LEMP stack. To do that, follow the steps below to properly and correctly install WordPress.

Step 1: Install the LEMP Stack

WordPress will run on top of the LEMP stack. To get WordPress working on LEMP, follow the link below to install it. This is the first step.

Step 2: Configure WordPress Database

If you read and followed step 1, LEMP should be installed and ready to use. Continue below to configure WordPress database. WordPress requires a database to store its content.

Run the commands below to logon to the database server. When prompted for a password, type the root password you created in the previous post above.

sudo mysql -u root -p

Then create a database called wordpress


Create a database user called wordpressuser with new password

CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'new_password_here';

Then grant the user full access to the database.

GRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;

Finally, save your changes and exit.


Step 3: Download WordPress Files and Configure

Now that you’ve installed all the servers and packages that WordPress needs, it’s time to download WordPress content. To download the content, run the commands below.

cd /tmp/ && wget

Next, extract the downloaded content by running the commands below.

tar -xvzf latest.tar.gz

After extracting WordPress’ content, move it to its DocumentRoot location by running the commands below.

sudo mv wordpress /var/www/html/wordpress

After moving WordPress content to its root directory, use the command below to make a copy of wp-config-sample.php file and name it wp-config.php.

The wp-config.php is the default configuration file for WordPress stored in its root directory.

sudo cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php

Next, edit wp-config.php file and make the below changes to reflect the database and user you created above.

sudo nano /var/www/html/wordpress/wp-config.php

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wordpress‘);

/** MySQL database username */
define(‘DB_USER’, ‘wordpressuser‘);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘new_password_here‘);

Save your changes when done.

Finally, run the commands below to set the correct files and folders permissions for WordPress to function properly.

sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html/

Step 4: Configure Nginx WordPress Config File

After all of the above steps, the last one is to create Nginx configuration file for WordPress. To do that run the commands below to create a new site config for WordPress called wordpress

sudo nano /etc/nginx/sites-available/wordpress

Then copy and paste the content below into the file and save it. Replace the highlighted line with your own domain name and directory root location.

server {
    listen 80;
    listen [::]:80;
    root /var/www/html/wordpress;
    index  index.php index.html index.htm;

    location / {
    try_files $uri $uri/ /index.php?$args;        

    location ~ \.php$ {
    fastcgi_split_path_info  ^(.+\.php)(/.+)$;
    fastcgi_index            index.php;
    fastcgi_pass             unix:/var/run/php/php7.1-fpm.sock;
    include                  fastcgi_params;
    fastcgi_param   PATH_INFO       $fastcgi_path_info;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;


Save the file and exit.

After configuring the VirtualHost above, enable it by running the commands below

sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/


To load all the settings above, restart Nginx by running the commands below.

sudo systemctl restart nginx.service
sudo systemctl start php7.1-fpm.service

After restarting Nginx, open your browser and browse to the server IP address or hostname. If everything was setup correctly, you should see WordPress default configuration wizard.
WordPress default setup page

Follow the on-screen instructions until you’re successfully configured WordPress. When you’re done, login to the admin dashboard and configure WordPress settings.

Congratulations! You’ve just successfully installed WordPress.

You may also like the post below:

7 Replies to “Install WordPress on Ubuntu 17.10 with Nginx, MariaDB and PHP-FPM (LEMP)”

      1. Today I tried 3 different tutorials most of them had the similar process like yours none of them seemed to work there might be some glitch somewhere.

    1. I have run into this problem too. So I fixed with this method and now it’s worked.

      1. sudo nano /etc/nginx/sites-available/default

      2. change root /var/www/html; to root /var/www/html/wordpress;

      reload nginx
      sudo systemctl restart nginx.service
      sudo systemctl start php7.2-fpm.service
      and try again

      If it said “Your PHP installation appears to be missing the MySQL extension which is required by WordPress”
      run the command: sudo apt-get install php-mysqlnd

      Hope this worked :D

  1. Gives error, nothing in the error.log, the problem seems to be that ngix is not recognizing php files and thus not parsing them and offering them for downloading instead

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.