Server - Contents


revised 05-Sep-2023

An Open-source Content Management System (CMS) Type of Website

Prerequisites: Basic Server (Ubuntu-20-04) with Webmin, FTP, Firewall and iRedmail
A fully-qualifed hostname. eg

Assumption with iRedMail: If the integrated approach expressed in this website is followed and a Wordpress application is desired, then iRedMail is to be installed prior to installing Wordpress - the reason being that the iRedMail will install the Nginx Webserver and MySQL/MariaSQL; their settings for iRedmail need to be preserved.
Establish a SSL Certificate: Such a certificate is now essential for establishing a website and should be done prior to installing Wordpress. See this link: SSL Certificate(s) for Websites

Preparation for Installing Wordpress

Ensure MySQL or MariaDB is installed
sammy@imega:sudo systemctl status mysql // Ctl-c to exit

If not installed, do the following:

sammy@imega:sudo apt update
sammy@imega:sudo apt install gnupg
sammy@imega:sudo dpkg -i mysql-apt-config*
sammy@imega:sudo apt update
sammy@imega:sudo apt install mysql-server

Ensure PHP is installed

Note: Check version of PHP installed if one has opted to first install iRedmail. Check with the command: php -v

sammy@imega:sudo apt -y install php-fpm // it currently installs php8.1-fpm
sammy@imega:sudo systemctl is-active php8.1-fpm.service //check status
sammy@imega:sudo apt -y install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip php-mysqlnd php-mysqli // additional support for Wordpress plugins

Preparation: Ensuring PHP-FPM works for local domain ( a critical requirement for WordPress

Step01:[Refer first to Basic Website-Part B on Nginx webserver] Remove the domain's (eg index.html and replace with the contents and filename of this index.php

sammy@imega:sudo mkdir /var/www/wordpress
sammy@imega:sudo nano /var/www/wordpress/index.php

Step02: Change, via Webmin ->[Nginx Webserver] the Nginx domain settings (eg. test this PHP file. The settings should look similar with this (with your own domain, not, and for reference see this text file: wordpress_nginx_example.txt

	server {
    listen         80;
    return         301$request_uri;
    return         301$request_uri;
server {
  listen         443 ssl;
  listen         [::]:443 ssl;
  root /var/www/wordpress;
  index index.php index.html index.htm;

    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;

    location / {
        #try_files $uri $uri/ =404;
        try_files $uri $uri/ /index.php$is_args$args;

  location ~ \.php$ {
   include snippets/fastcgi-php.conf;
   #fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
Note: If opening the website gives 'Bad Gateway', do the following:
open: sudo nano /etc/php/8.1/fpm/pool.d/www.conf
Check that 'owner'and 'group' are set as: www-data
that: listen =

With Nginx restarted and if all is successful, the browser result is 'Hello world'.

Create a MySQL/MariaSQL user and database for Wordpress

Step03: With same the root MySQL/MariaSQL password used in setting up iRedmail (logon to the postmaster's mailbox (eg. to retrieve such details), enter, via PuTTY, the following 4 commands (create in advance: at least a strong userpassword. One can also change the username [eg. wordpressuser] and database name [wordpressdb] other than those suggested below):

sammy@imega: sudo mysql -u root -p // 'MySQL' root & password
mysql@imega:CREATE DATABASE wordpressdb;
mysql@imega:CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'user_password_here';
mysql@imega: ALTER USER 'wordpressuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'user_password_here';
mysql@imega:GRANT ALL PRIVILEGES ON wordpressdb.* TO wordpressuser@localhost;
mysql@imega:show grants for 'wordpressuser'@'localhost'; // to check all is correct
Type "exit" to resume as sammy.

Installing Wordpress

Tip#01: The wordpress application will not accept 'root' as a wordpress-user. One will get a connection error to the database if 'root' is used.

Step04: Install Wordpress application on the server.

Logon to the server via PuTTY (regular user eg. sammy), and enter these commands:

sammy@imega: cd /var/www
sammy@imega: sudo rm -Rf wordpress/
sammy@imega: sudo wget
sammy@imega: sudo tar xzvf latest.tar.gz
sammy@imega: sudo cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php
sammy@imega: sudo chown -R sammy:www-data /var/www/wordpress/
sammy@imega: sudo chmod -R 755 /var/www/wordpress/
sammy@imega: curl -s //**
sammy@imega: sudo nano /var/www/wordpress/wp-config.php
**Copy the output which begins with: define('AUTH_KEY',.. in the appropriate area of the config file.

With the file:wp-config.php opened for editing, change these three top settings:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpressdb');

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

/** MySQL database password */
define('DB_PASSWORD', 'user_password_here');

Remember to refresh the changes in Nginx.

Step05: Open browser to the domain and follow Wordpress instructions.

reference install-wordpress-ubuntu-20-04

Wordpress Wordpress Backup