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
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.
- I first tried installing Centos (CentOS-Stream-9-latest-x86_64-dvd1.iso) – because it related to RedHat which is the most highly used version of Linux for Servers in the corporate word. However, I had issues with installing the Guest Additions into Centos. I struggled for about a day and then gave up.
- I then installed Ubuntu Desktop (ubuntu-24.04-desktop-amd64.iso). Ubuntu is more widely used.
See: https://medium.com/@selvarajk/centos-linux-installation-in-virtualbox-719086f37e22
- Download Ubuntu from https://ubuntu.com/download/desktop/thank-you?version=24.04&architecture=amd64<s=true
- The file name is: ubuntu-24.04-desktop-amd64.iso
- Open VirtualBox and click on New and fill out the form as shown below (use the ubuntu iso – not the centos one).
Storage Requirements
How much resources will this need?
- Linux: 6GB
- WordPress: 1GB
- Plugins – maybe 1 GB
- MariaDB: 2.1 GB
- PhP: 256 MB
- Java JDE: 200MB
- Intellij IDEA: 3.5 GB
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
- Shutdown the Linux Guest
- Add Storage as shown below using file: C:\Program Files\Oracle\VirtualBox\VboxGurestAdditions.iso
- I had an issue with the .vdi file not getting created. so click on preallocate stoate (to 35GB) and Create Now.
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
I did not install this pack. I used a USB key to transfer files into my Ubuntu guest.
Apparently, this extension pack allows one to load files into the Guest Linux system using USB.
To install this pack, one needs to download and Install: extension pack for VirtualBox 7.0
You install the extension using the command: File – Tools – Extension Pack Manager
Install nginx
The Next step is to install nginx (pronounced Engine X). nginx is a highly performant Web server. The other option is Tomcat, but NginX is more performant and uses an event driven architecture.
You can install nginx by typing this command:
sudo apt install nginx
After the installation, check the status of NGINX. If it’s active (running), you have installed nginx successfully.
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:
- Enter current password for root (enter for none):
Just press the Enter
- Switch to unix_socket authentication [Y/n]: n
- Change the root password? [Y/n]:
Y
- New password:
Enter password
- Re-enter new password:
Repeat password
- Remove anonymous users? [Y/n]:
Y
- Disallow root login remotely? [Y/n]:
Y
- Remove test database and access to it? [Y/n]:
Y
- Reload privilege tables now? [Y/n]:
Y
Now, you can login to MariaDB
by running this command:
$ sudo mysql -u root -p
Configure Database
To configure WordPress, we need to create MariaDB
database. Let’s do it!
Access MariaDB commands:
$ sudo mysql -u root -p
The output will look similar to this:
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)]>
Create database:
MariaDB> CREATE DATABASE wordpress;
Grant access:
MariaDB> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
-> ON wordpress.*
-> TO wordpress@localhost
-> IDENTIFIED BY '<your-password>';
Do not forget to replace <your-password>
with your password.
In order to apply the changes above without reloading or restarting mysql service we need to flush the table:
MariaDB> FLUSH PRIVILEGES;
Exit MariaDB commands:
MariaDB> EXIT;
From now on, you can connect to the database using the command below:
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
Download and extract the latest version of WordPress:
cd /tmp && wget https://wordpress.org/latest.tar.gz
Then extract the package using:
$ tar -xzvf latest.tar.gz
This command will produce a folder called wordpress
, copy this file to /var/www/html/
by the following command:
$ sudo cp -R wordpress /var/www/html/
Exit /tmp
directory and run the following command to create upload
folder for wordpress:
$ sudo mkdir /var/www/html/wordpress/wp-content/uploads
Configure WordPress
Configure WordPress
to use the installed database. First create /var/www/html/wordpress/wp-config.php
by running the following command:
$ sudo nano /var/www/html/wordpress/wp-config.php
Enter the following, and don’t forget to enter the password that you have used earlier for the database:
apt install net-tools
ifconfig
Get your IP address:
ip a
Now you can proceed to your web URL server hostname or IP address/wordpress
in your browser. And start installing and configure WordPress:
http://server-ip/wordpress
Change File Permissions
as root, type the following commands:
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
Leave a Reply