Let's migrate Apache2 to Nginx to increase WordPress website performance.
sudo apt update
sudo apt upgrade
sudo apt install nginx
sudo ufw allow "Nginx Full"
Open file with editor
sudo vi /etc/nginx/sites-available/default
Change port to 8080
listen 8080 default_server;
listen [::]:8080 default_server;
Test configuration before apply
sudo nginx -t
Start Nginx server
sudo service nginx start
Test connection
curl http://localhost:8080
Create a new config file
sudo touch /etc/nginx/sites-available/zemna.net.conf
Open config file using editor
sudo vi /etc/nginx/sites-available/zemna.net.conf
Update configuration
server {
listen 80;
listen [::]:80;
root /var/www/zemnanet-website/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name zemna.net www.zemna.net;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
}
Activate configuration
sudo ln -s /etc/nginx/sites-available/zemna.net.conf /etc/nginx/sites-enabled/
sudo service apache2 stop
sudo srvice nginx start
Install required package
sudo apt install python-certbot-nginx -t stretch-backports
Obtaining an SSL Certificate
sudo certbot --nginx -d zemna.net -d www.zemna.net
sudo apt remove apache2
sudo apt autoremove
Remove from firewall configuration
sudo ufw delete allow "WWW Full"