Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi @affyboy,
It’s possible this is an issue with your PHP-FPM config. Check it out, see if it’s working properly, you can configure it listen to a port and redirect the requests there just to make sure everything is being executed as expected.
The issue lies in the Nginx configuration for handling PHP files within the /blog subfolder. Specifically, the PHP files in /blog are not being passed to PHP-FPM for processing. Instead, they are served as static files, which causes the browser to download them.
Here’s how you can adjust your Nginx server block to ensure PHP files under /blog are executed correctly:
server {
server_name mydomain.com www.mydomain.com 123.456.789.123;
root /var/www/html/vue/mydomain/dist;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
alias /home/mydomain/src;
}
location / {
try_files $uri $uri/ /index.html /index.php;
}
location ^~ /rest-auth/ {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
location ^~ /api/ {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
location ~ /\.ht {
deny all;
}
location ^~ /admin {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
location ^~ /blog {
root /var/www/html; # Ensure correct root for the blog
index index.php index.html index.htm;
try_files $uri $uri/ /index.php;
# Pass PHP files to PHP-FPM
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
# PHP settings at the root level
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_log /var/log/nginx/mydomain-error.log;
access_log /var/log/nginx/mydomain-access.log;
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
}
server {
if ($host = www.mydomain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = mydomain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name mydomain.com www.mydomain.com 123.456.789.123;
return 404; # managed by Certbot
}
Updated /blog Location Block:
/blog are handled by PHP-FPM.root as /var/www/html since the alias directive caused issues with relative paths.fastcgi_param Configuration:
SCRIPT_FILENAME to pass the correct file path to PHP-FPM.Fallback for /blog/index.php:
try_files $uri $uri/ /index.php; to ensure requests fall back to index.php.After making these changes, restart Nginx to apply the configuration:
sudo nginx -t # Test configuration for errors
sudo systemctl reload nginx