thanks for looking into my question.
I'm setting up a VPS using Ubuntu and Nginx, with the goal of hosting multiple WordPress websites. So far I've managed to get Phpmyadmin running on the subdomain pma.mydomain.com, and it's handling php like it should.
However, when I created all necessary items for hosting a website on the main domain (directory, server block, WP-files) it will not render the php. Either it displays a blank page (when looking at the source of the page, you see raw php code), or it tries to download the php file.
It's a fresh install - mysql, php8.1 is working and running, ufw firewall is not blocking any ports, the nginx.conf is (probably?) allright (hence the working phpmyadmin subdomain). Did I use the wrong php-code in the mydomain.conf? (see below). I'm totally lost at this point. Thanks in advance. Sorry about the certbot making it more difficult to read.
server {
listen 80;
listen [::]:80;
root /var/www/mydomain;
index index.php index.html index.htm index.nginx-debian.html;
server_name mydomain.com www.mydomain.com;
access_log /var/log/nginx/mydomain_access.log;
error_log /var/log/nginx/mydomain_error.log;
client_max_body_size 100M;
location ~ / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
include fastcgi_params;
fastcgi_pass unix:var/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mydomain.com/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
add_header Strict-Transport-Security "max-age=31536000" always; # managed by Certbot
ssl_trusted_certificate /etc/letsencrypt/live/mydomain.com/chain.pem; # managed by Certbot
ssl_stapling on; # managed by Certbot
ssl_stapling_verify on; # managed by Certbot
}
server {
if ($host = mydomain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
root /var/www/mydomain/;
index index.php index.html index.htm index.nginx-debian.html;
server_name mydomain.com www.mydomain.com;
access_log /var/log/nginx/mydomain_access.log;
error_log /var/log/nginx/mydomain_error.log;
client_max_body_size 100M;
location ~ / {
try_files $uri $uri/ /index.php;
}
location ~ \.php {
include snippets/fastcgi-php.conf;
include fastcgi_params;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
}
}