Install WordPress 5 with Nginx, MariaDB, and PHP 7 on Ubuntu 18.04
WordPress 5 was recently released with some fundamental changes, such as the Gutenberg editor, which is wonderful. In this article we will configure WordPress 5 with NGINX, MariaDB 10 and PHP 7 on Ubuntu 18.04.
If you want to have a blog or even a website, WordPress is the ideal choice. And version 5 has improved a lot.
In this article we will cover the installation of WordPress 5 on a fresh Ubuntu 18.04 Linux (with nothing installed).
As a web server, we will install the NGINX, which is an excellent web server, much lighter than Apache, ideal for virtual machines.
We will also install PHP 7, which is undoubtedly the best option for WordPress, since it is capable of running 5x faster than its predecessor, PHP 5.
As a database, we will install the Open Source FORK of MySQL, which is MARIADB version 10, which is also very robust and powerful.
Ubuntu Update
The first step is to update Ubuntu to make sure you have the latest updates and fixes:
sudo apt update && sudo apt upgrade
Install Nginx Web Server
Now let's install Nginx, start the service and then enable it to start at system boot:
sudo apt install nginx
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
If you want to learn more about Nginx, check out the Nginx course from Certificação Linux.
Configure Nginx for WordPress
Now let's configure Nginx to work with WordPress by creating the site configuration file. For that we will edit the file with vim. You can use another editor if you prefer.
sudo vim /etc/nginx/sites-available/wordpress.conf
Now paste the content below into the file:
server {
listen 80;
listen [::]:80;
root /var/www/html/wordpress;
index index.php index.html index.htm;
server_name _ meusite.com.br www.meusite.com.br;
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;
}
}
Don't forget to change meusite.com.br and www.meusite.com.br. If you want to learn more about DNS, we have a DNS Bind 9 course.
Now, let's create the symbolic link of the configuration file, and also delete the default site configuration:
sudo ln -s /etc/nginx/sites-available/wordpress.conf /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-available/default
sudo systemctl reload nginx
Install MariaDB
Now let's install MariaDB version 10. After installation we will start the service and then set it to start at boot.
If you want to make your default MySQL database super optimized, check out our MySQL tuning course.
sudo apt install mariadb-server mariadb-client
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
Now, we recommend you run the MySQL security script. Basically you will set a root password, disable anonymous access and remove the test database.
sudo mysql_secure_installation
Create the WordPress Database and Access User
Now let's access the database with the root password you set in the previous step, create the database and also create the WordPress user.
sudo mysql -u root -p
Now, inside the MySQL shell, enter the following commands. Don't forget to change the password:
The user will be: wp_user and the password you define.
CREATE DATABASE wordpress;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'troque_a_senha';
GRANT ALL ON wordpress.* TO 'wp_user'@'localhost' ;
FLUSH PRIVILEGES;
EXIT;
Install PHP 7
Now let's install PHP 7 on the server. Right after we will enable the service and also set it to start at system boot.
sudo apt install php-fpm php-common php-mbstring php-xmlrpc php-soap php-gd php-xml php-intl php-mysql php-cli php-ldap php-zip php-curl
sudo systemctl start php7.2-fpm
sudo systemctl enable php7.2-fpm
Finally, Install WordPress 5
Now let's download the latest version of WordPress 5.
cd /tmp && wget http://wordpress.org/latest.tar.gz
sudo tar -xvzf latest.tar.gz -C /var/www/html
sudo chown www-data: /var/www/html/wordpress/ -R
sudo service nginx reload
Configure WordPress for the First Time
Now that WordPress is installed, it's time to configure access. For that, you must access the server through your preferred browser.
Enter your server address or its IP. If everything went right you will see a screen like this:

Choose Portuguese (Brazil) and click next to configure the database. Change the user to wp_user and enter the password you chose when creating the user wp_user.

Done that, the next step is to configure your Site Name and your user to log into WordPress.

Now it's time to log into your WordPress:

Voilà. Your WordPress 5 with MariaDB 10, Nginx and PHP 7 is ready for use:

Learn much more about Linux in our online course. You can enroll here with a 7-day free trial. If you already have an account, you can access here.
Did you like it? Share :-)
That was just one piece. The course teaches the whole path — from your first command to exam day.