Rebuild VPS/Blog

Quite overdue. I need to fill all the gaps properly

I went from Apache to NGINX to make it more challenging for me…

Make a proper backup of your VPS.

More details

Get latest Debian stable

Or try to upgrade…link:

SSL Cert

Be sure you have Let’s Encrypt setup for getting your free. Good thing, the DNS side was already done so it was just to configure NGINX

WordPress

Link.

phpMyAdmin

Link. I struggled with this. I had to make a minimal config and then put my backup. After that, I had my blog fully recover

NGINX config

Link. I struggled here because I had to serve my blog and phpadmin from nginx. I knew how to do it via Apache but was failing with nginx. I asked ChatGPT and at the end it gave me the solution

This is the final config:

server {
    server_name thomarite.uk blog.thomarite.uk;
    root /var/www/html/wordpress;
    index index.php;

    access_log /var/log/nginx/thomarite.uk.access.log;
    error_log /var/log/nginx/thomarite.uk.error.log;

    client_max_body_size 100M;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        include fastcgi_params;
        fastcgi_intercept_errors on;
    }

    location /phpmyadmin/ {
        alias /usr/share/phpmyadmin/;
        index index.php;

        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
            include fastcgi_params;
            fastcgi_intercept_errors on;

            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }
    }

    location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
        add_header Access-Control-Allow-Origin "*";
        expires 90d;
        access_log off;
    }

    location ~ /\.ht {
        access_log off;
        log_not_found off;
        deny all;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/thomarite.uk-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/thomarite.uk-0001/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
    if ($host = blog.thomarite.uk) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = thomarite.uk) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    listen [::]:80;
    server_name thomarite.uk blog.thomarite.uk;

    location / {
        return 404;
    }
}


Then

sudo nginx -t
sudo service nginx restart

IRCD

I need to check how this is installed properly. Check this.