currently I’m trying to run a php file on my nginx server. I downloaded all packages, changed the config file, but it is still not working. I can open my index.html, but when I open my php file it just downloads it.
My code of the config file:
server {
listen 80 default_server;
root /var/www/html;
index index.html index.htm index.php index.nginx-debian.html;
server_name test;
location / {
try_files $uri $uri/ =404;
}
location ~ .php$ {
try_files $uri $uri/ =404;
include snippets/fastcgi-php.conf;
fastcgi_pass unix: /var/run/php/php8.0-fpm.sock
}
}
Please help me.
2
Answers
Try this I pulled from a working server
I only changed the fpm and server name since well the server is using 7 and the server_name was the ip of the server…I put yours
Your configuration file is invalid, and It may not applied. Try this and run
sudo nginx -t && sudo systemctl restart nginx
.