T&F

TRUTH & FAITH

Step 1 — Installing the Nginx Web Server

sudo apt update
sudo apt install nginx

Step 2 — Installing MySQL to Manage Site Data

sudo apt install mysql-server
sudo mysql_secure_installation

Step 3 — Installing PHP 7.3 for Processing

apt-get install ca-certificates apt-transport-https lsb-release

wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php7.3.list

apt-get update

sudo apt install php7.3-cli php7.3-fpm php7.3-json php7.3-pdo php7.3-mysql php7.3-zip php7.3-gd  php7.3-mbstring php7.3-curl php7.3-xml php7.3-bcmath php7.3-json

sudo vim /etc/php/7.3/fpm/php.ini

Then scroll down the file line by line and adjust each directive with the value below:

memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 64M
file_uploads = On
max_execution_time = 600
max_input_time = 600

Step 4 — Configuring Nginx to Use the PHP Processor

sudo mkdir /var/www/your_domain
sudo vim /etc/nginx/sites-available/your_domain

This will create a new blank file. Paste in the following bare-bones configuration:/etc/nginx/sites-available/your_domain

server {
    listen 80;
    listen [::]:80;

    root /var/www/your_domain;
    index index.php index.html index.htm;

    server_name your_domain;
    client_max_body_size 64M;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        fastcgi_connect_timeout 300s;
        fastcgi_read_timeout 300s;
        fastcgi_send_timeout 300s;
    }

    if (!-e $request_filename) {
            rewrite ^.*$ /index.php last;
    }
}

Activate your configuration by linking to the config file from Nginx’s sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/ 

sudo nginx -t
sudo systemctl reload nginx

Step 5 — Create a PHP File to Test Configuration

sudo vim /var/www/your_domain/info.php
<?php
  phpinfo();
?>

Step 6 — Creating a MySQL Database and User for WordPress

sudo MySQL

CREATE DATABASE your_domain DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

GRANT ALL ON your_domain.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

FLUSH PRIVILEGES;

EXIT;

Step 7 — Check PHP Extensions

sudo apt update
sudo systemctl restart php7.3-fpm

Step 8 — Downloading WordPress

curl -LO https://wordpress.org/latest.zip
sudo mkdir /var/www/html/your_domain
sudo unzip -d /var/www/html/your_domain latest.zip
sudo chown -R www-data:www-data /var/www/your_domain

sudo nginx -t
sudo systemctl reload nginx

Step 9 — Installing Certbot

sudo apt install python-certbot-nginx -t stretch-backports

Step 10 — Obtaining an SSL Certificate

sudo certbot --nginx -d example.com -d www.example.com

Step 11 — Verifying Certbot Auto-Renewal

sudo certbot renew --dry-run

Leave a Reply

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