<mohammadrony>

WordPress

Installation notes

PHP

sudo apt update
sudo apt install -y php ghostscript php-bcmath php-curl php-imagick php-intl php-json php-mbstring php-mysql php-xml php-zip php-cli php-fpm php-opcache php-gd
sudo systemctl enable --now php-fpm
sudo systemctl status php-fpm

MySQL

sudo apt install -y mysql-server
sudo mysql -u root -p
CREATE DATABASE wordpressdb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'wp_password'
GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wp_user'@'localhost'

Application

cd /var/www/
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xvzf latest.tar.gz
sudo rm -rf latest.tar.gz
sudo chown -R www-data: /var/www/wordpress/
cd /var/www/wordpress
sudo cp wp-config-sample.php wp-config.php
sudo sed -i 's/database_name_here/wordpressdb/' wp-config.php
sudo sed -i 's/username_here/wp_user/' wp-config.php
sudo sed -i 's/password_here/wp_password/' wp-config.php
sudo sed -i 's/localhost/localhost/' wp-config.php

Nginx

sudo apt install -y nginx
sudo tee /etc/nginx/sites-available/wordpress.conf << EOF
server {
    listen 80;
    listen [::]:80;

    server_name example.com www.example.com;
    access_log /var/log/nginx/wordpress-access.log;
    error_log  /var/log/nginx/wordpress-error.log error;

    root /var/www/wordpress;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ /\.ht {
        deny all;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

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

    location ~ \.php$ {
       include snippets/fastcgi-php.conf;
       fastcgi_pass unix:/var/run/php/php-fpm.sock;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       include fastcgi_params;
    }
}
EOF
cd ../sites-enabled/
sudo ln -s ../sites-available/wordpress.conf ./
``

```sh
sudo systemctl reload nginx

Certificate

sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d www.example.com

Browse Application

Open wordpress from browser.