不是执行.php,而是下载。
我正在尝试在Ubuntu 16.04 LTS上配置php7,我的/ etc / nginx / sites-available / default看起来像这样。
有人可以帮忙吗?
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name mydomain.com www.mydomain.com;
return 301 https://$server_name$request_uri;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
server {
index index.html index.htm index.nginx-debian.html;
# SSL configuration
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
include snippets/ssl-mydomain.com.conf;
include snippets/ssl-params.conf;
location /web {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://localhost:32400/web/;
}
}
答案 0 :(得分:0)
您将所有内容重定向到https,而您的https服务器部分不处理PHP,请参阅缺少fastcgi
配置。
答案 1 :(得分:0)
看起来您的第二个服务器(ssl)块缺少location ~ \.php$
块。这就是告诉nginx执行PHP而不是原始服务的原因。
换句话说,请试一试:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name mydomain.com www.mydomain.com;
return 301 https://$server_name$request_uri;
location / {
try_files $uri $uri/ =404;
}
}
server {
index index.html index.htm index.nginx-debian.html;
# SSL configuration
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
include snippets/ssl-mydomain.com.conf;
include snippets/ssl-params.conf;
location /web {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://localhost:32400/web/;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}