
Following the series of tutorials WordPress and Ubuntu, in this article, we are going to Install WordPress with LEMP on Ubuntu 18.04. As many of our readers might want to test it on their own server, today we present how to setup WordPress 5 with LEMP on Ubuntu 18.04. And you know that the LEMP is a popular combination of Linux, Nginx, MySQL/MariaDB, and PHP.
Table of Contents
Requirements
- A dedicated server or a VPS (Virtual Private Server) with Ubuntu 18.04 minimal installation
Install WordPress with LEMP on Ubuntu 18.04
Let’s walk through this guide, to see the installation of all the required packages, creating your own database, preparing vhost, and completing the WordPress installation via a browser.
Installing Nginx Web Server on Ubuntu 18.04
After preparing your web server Nginx, run the following command to install the package.
sudo apt update && sudo apt upgrade sudo apt install nginx
sudo systemctl start nginx.service sudo systemctl enable nginx.service
Creating Vhost for WordPress Website on Nginx
sudo vim /etc/nginx/sites-available/wordpress.conf
server { listen 80; listen [::]:80; root /var/www/html/wordpress; index index.php index.html index.htm; server_name example.com www.example.com; 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; } }
sudo ln -s /etc/nginx/sites-available/wordpress.conf /etc/nginx/sites-enabled/
sudo systemctl reload nginx
Installing MariaDB 10 on Ubuntu 18.04
You need to use MariaDB for your WordPress database, so install it by typing:
sudo apt install mariadb-server mariadb-client
sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
then, use the following command to secure your MariaDB installation.
sudo mysql_secure_installation
Creating a WordPress Database for Website
sudo mysql -u root -p
CREATE DATABASE wordpress; CREATE USER 'wp_user'@'localhost' IDENTIFIED BY ‘secure_password’; GRANT ALL ON wordpress.* TO 'wp_user'@'localhost' ; FLUSH PRIVILEGES; EXIT;
Installing PHP 7 on Ubuntu 18.04
Install PHP and the required PHP packages to run WordPress, as WordPress is an application written in PHP.
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
Start the php-fpm service and enable it, when the installation is complete.
sudo systemctl start php7.2-fpm systemctl enable php7.2-fpm
Installing WordPress 5 on Ubuntu 18.04
Now, download the latest WordPress package.
cd /tmp && wget http://wordpress.org/latest.tar.gz
And extract the archive with:
sudo tar -xvzf latest.tar.gz -C /var/www/html
Till here, you would create your document root that we have set in the vhost which is /var/www/html/wordpress. Next, you need to change the ownership of the files and folders within that directory with:
sudo chown www-data: /var/www/html/wordpress/ -R
In case you have used unregistered/non-existing domain, you can configure your hosts /etc/hosts file, as you are ready to run the installation of your WordPress.
192.168.1.100 example.com
Consider that your server’s IP address is 192.168.1.100 and the domain you are using is example.com as well your computer resolves example.com on the given IP address.
Load your domain into a browser to see the WordPress installation page:
Then, you can see the database credentials that we have set up earlier:
As you see below, you need to submit the form and on the next screen configure your website title, admin user, and email:
Good job! You finished the installation here and from now on you can start managing your WordPress website. we suggest you start by installing some fresh new themes or extending the site functionality via plugins.
Dear user, we wish this tutorial install WordPress with Nginx, MariaDB, and 10 PHP 7 on Ubuntu 18.04 would be helpful for you, to ask any question or review the conversation of our users about this article, please visit Ask page. Also to improve your knowledge, there are so many useful tutorials ready for Eldernode training.
You may also be interested in :
Install WordPress with LEMP on Ubuntu 18.04