Reputation: 1432
I'v configured Ngnix server on CentOs 7 and it is working find with html but when I'm trying to open .php file it is downloaded. I'm using Php7.2. Here is my configuration(I'm using 123.123.123.123 instead my real ip):
server {
listen [::]:80 default_server ipv6only=on;
listen 123.123.123.123:80 default_server;
root /var/www/example.com/public_html;
index index.php index.html;
server_name 123.123.123.123;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
So when I'm trying to access to 123.123.123.123/test/index.php I'm geting file download.
How could I force ngnix to execute php files?
Upvotes: 0
Views: 919
Reputation: 11158
You also need fastcgi_pass:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Upvotes: 1