Debian | Provisioning of WordPress with Nginx 1.16

The following components are used in my lab

  • Debian 10
  • Nginx 1.16 (Default Nginx is 1.14 from Debian)
  • MariaDB 10.3.18
  • PHP 7.3
  • WordPress 5.3.2

Installation of Nginx 1.16

#Official Repository from Nginx 
echo "deb buster nginx" | sudo tee -a /etc/apt/sources.list.d/nginx.list
echo "deb-src buster nginx" | sudo tee -a /etc/apt/sources.list.d/nginx.list

#Install Dependency - curl & gnupg 
sudo apt-get install curl gnupg -y

#Add the signing key 
curl -L | sudo apt-key add -

#Update and install nginx
sudo apt-get update 
sudo apt-get install nginx -y

#verify nginx version installed
sudo nginx -v
    nginx version: nginx/1.16.1

#Start and Enable Nginx on startup
sudo systemctl start nginx 
sudo systemctl enable nginx

Backup the default Nginx configuration file

#Make a copy of the default nginx configuration file 
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak

Installation of MariaDB 10.3

sudo apt install mariadb-server mariadb-client -y

#systemctl enable mariadb
sudo systemctl enable mariadb

#Assign Password to login to MariaDB
sudo mysql

ALTER USER root@localhost IDENTIFIED VIA mysql_native_password;
SET PASSWORD = PASSWORD('P@ssw0rd!@#$');
flush privileges;

#Secure MariaDB by accepting all the default values 
sudo mysql_secure_installation

Installation of PMP 7.3

#Install PHP7.3
sudo apt install php-fpm php-mysql -y

#Add index.php for Ngnix to precess PHP pages
sudo nano /etc/nginx/conf.d/default.conf

server {
    listen       80;
    #Change the root document to /var/www/html/UAT
    root         /var/www/html/UAT;

    location / {
        root   /var/www/html/UAT;
        index  index.php;

    #Copy the PHP Configuration below
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        fastcgi_param  SCRIPT_FILENAME  /var/www/html/UAT/$fastcgi_script_name;
        include fastcgi_params;

#Create a new Folder 
sudo mkdir -p /var/www/html/UAT
#Copy the default index.html 
sudo cp /usr/share/nginx/html/index.html /var/www/html/UAT/
#Assign www-data group as the owner for the new folder
sudo chown -R www-data:www-data /var/www/html/UAT
#Add nginx user to www-data group
sudo usermod -aG www-data nginx
#Restart both nginx & PHP fpm services
sudo systemctl restart php7.3-fpm nginx

#Test PHP Processing
echo "<?php phpinfo();" | sudo tee -a /var/www/html/UAT/test.php

#Test nginx configureation and restart
nginx -t
systemctl restart nginx php7.3-fpm

#Access to the link below, and you should be able to see the PHP version

#Install Extra PHP Extension for wordpress
sudo apt-get install php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip -y

Configure MariaDB for WordPress

#Set the Authentication Key and Salts
curl -s

#Edit the wordpress configuration file 
nano /var/www/html/UAT/wp-config.php 

/** The name of the database for WordPress */
define( 'DB_NAME', 'UAT' );

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

/** MySQL database password */
define( 'DB_PASSWORD', 'P@ssw0rd' );

#Delete this 
define( 'AUTH_KEY',         'put your unique phrase here' );
define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
define( 'NONCE_KEY',        'put your unique phrase here' );
define( 'AUTH_SALT',        'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
define( 'NONCE_SALT',       'put your unique phrase here' );

#And replace with our own key generated
define('AUTH_KEY',         'biz!ah#n$T/8;WGM4?rz3%y?e|iovh6<p1_#4@+MVOI*E F ~f2[xPh}JwdK6`hS');
define('SECURE_AUTH_KEY',  '@x6y/,BD`m>@m|ieyjIQt; VVAZj[y(QL$fkvg.mlp!x>.`Ky#:%9Ncr]s$11EdB');
define('LOGGED_IN_KEY',    'C|(ugvrt4%hOyU:<$e9NN~3w6Fm:XLeFNB{p;JcY#8]<gUA|u|%+Oo[Fs$0fJE^i');
define('NONCE_KEY',        '|,n-w9fY#fyi?(>^gxd{PDY>`%I:.l5WC:0e=e^C=Bb~+j[;(3H{6%(tl5fJ`02B');
define('AUTH_SALT',        '^7a2$YQ(,Ls`@L)LB=;P%M;i 7Vz7!}J*/TosOR|[IK+~L mXDIhb5)hVy(vX+7y');
define('SECURE_AUTH_SALT', 'vq%B_GHD`%0JZGnP:o_nL8n@mz@c9Lxq++-L^yOZD29XyJqeF?:XNAhr.R)Wpaiw');
define('LOGGED_IN_SALT',   '<Z/6%Ui4[.Uyi[7B9O=u!PP1LWYGn;g2#(9p<@+27xJ5%ra7A*1-8<w>H+IHPZ0~');
define('NONCE_SALT',       'Q!:j=~+PVgih<z,kId-5]M!oLlGg~.9r}aWR9k>^#ab<-U3h|qpIV2t|;_AlQt?<');

Change the owner of /var/www/html/UAT to www-data

sudo chown -R www-data:www-data /var/www/html/UAT

Restart nginx & php7.3 fpm

#Restart both nginx & PHP fpm services
systemctl restart php7.3-fpm nginx

Go to to complete the wordpress installation with GUI

Scroll to Top