WordPress installation on Linux with Nginx, PHP and Maria

This post contains a Step by Step Guide for installing WordPress on an Ubuntu Linux host along with Nginx, PHP, and MariaDB.

Contents

Oracle VM Virtual Box Manager

See Link: https://netshop-isp.com.cy/blog/how-to-install-wordpress-on-centos-7-with-mariadb-10-nginx-and-php-fpm-7/

Install the latest version of Virtual Box (VirtualBox-7.0.20-163906-Win.exe) on your Laptop.

  • My Laptop is an Lenovo IdeaPad 5 15IAL7.
  • The CPU is: i7-1255U 1.7 GHz
  • Memory: 16 GB of RAM
  • 10 cores.
  • Windows 11 Home.
  • Storage: 474 GB SSD

Linux

The first step is to install Linux.

See: https://medium.com/@selvarajk/centos-linux-installation-in-virtualbox-719086f37e22

Storage Requirements

How much resources will this need?

This adds up to about 14GB. So 25 GB should be enough for a Development Environment.
Disk in VirtualBox is dynamically allocated and can be increased layter, so I configured the Storage as shown below.

Hardware

In terms of Hardware, I configured the machine with 2 GB of Memory and 4 CPUs.
These resources can always be changed later.

Install VirtualBox Additions

Start the Guest Linux system and run the following commands on the command line.
When you reboot, you must save the state or you might have to rebuild the machine from the iso again.

sudo su - root
apt update
apt upgrade
sudo apt-get install virtualbox-guest-additions-iso
shutdown nowdu -s

Display Settings

To enable full screen view, change the settings from within Ubuntu.
I have two windows screens: 1680 x 1050, 1920 x 1080 and 1920 x 1080.
I therefore configure Ubuntu with 1680 x 1050 – which was as high as it could go.

Login loop

If you can’t login, because you just see a blank coloured screen, then read this article:

https://support.system76.com/articles/login-loop-ubuntu

Extension Pack

Install nginx

sudo apt install nginx
systemctl status nginx

Install MariaDB

To install Maria, type the following command;

sudo apt-get install mariadb-server mariadb-client

Start and enable Apache2 service:

$ sudo systemctl stop mysql.service
$ sudo systemctl start mysql.service
$ sudo systemctl enable mysql.service

After that, by running the coming command, MariaDB server will be secured, by creating a root password and disallowing remote root access.

Run MariaDB configuration script:

$ sudo mysql_secure_installation

Now, answer the following questions as below:

Now, you can login to MariaDB by running this command:

$ sudo mysql -u root -p

Configure Database

$ sudo mysql -u root -p
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 81
Server version: 10.0.38-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
MariaDB> CREATE DATABASE wordpress;
MariaDB> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
    -> ON wordpress.*
    -> TO wordpress@localhost
    -> IDENTIFIED BY '<your-password>';
MariaDB> FLUSH PRIVILEGES;
MariaDB> EXIT;
mysql -u wordpress -p wordpress

Install PHP

Install PHP by typing this command:

I had an issue when installing PPP. nginx failed to start. I discovered that Apache had been installed and was using port 80.

so I had to uninstall apache later. (sudo systemctl disable apache2) (apt remove apache2) So one of the packages listed below, may include Apache2 and should not be installed (not sure). I did a bit of googling and it looks like this is a common problem on ubuntu.

sudo su - root
apt update
apt install php libapache2-mod-php php-mysql
apt install php-mysql php-cgi php-cli php-gd -y 

Install WordPress

cd /tmp && wget https://wordpress.org/latest.tar.gz
$ tar -xzvf latest.tar.gz
$ sudo cp -R wordpress /var/www/html/
$ sudo mkdir /var/www/html/wordpress/wp-content/uploads

Configure WordPress

$ sudo nano /var/www/html/wordpress/wp-config.php
apt install net-tools 
ifconfig

Get your IP address:

ip a
http://server-ip/wordpress

Change File Permissions

chown -R www-data:www-data /var/www/html
chmod -R 755 /var/www/html
ls -l /var/www/html

What’s Running?

To find out what is running, execute the following command:

systemctl --type=service --state=running

Accessing the Site

Use the Firefox web browser on the ubuntu Linux desktop, and go to http://127.0.0.1/wordpress

PHP-FPM

PHP-FPM (FastCGI Process Manager) is an alternative to FastCGI implementation of PHP with some additional features useful for sites with high traffic. It is the preferred method of processing PHP pages with NGINX and is faster than traditional CGI based methods such as SUPHP or mod_php for running a PHP script. The main advantage of using PHP-FPM is that it uses a considerable amount of less memory and CPU as compared with any other methods of running PHP. The primary reason is that it demonizes PHP, thereby transforming it to a background process while providing a CLI script for managing PHP request.

see: https://www.digitalocean.com/community/tutorials/php-fpm-nginx

sudo su - root
apt-get install php-fpm
systemctl status php8.3-fpm

Tagged in :

dconnell@hotmail.co.nz Avatar

Leave a Reply

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