繁体   English   中英

nginx将php请求传递给php-apache服务器,但下载而不是执行php文件

[英]nginx pass php request to a php-apache server , but download instead of executing the php files

我设置了2台服务器,一台服务器是nginx,端口80。 B服务器是apache的php,端口为80。 如果我访问B:80 / index.php,它将正常运行。

在服务器A上,nginx conf:

location ~ .*\.php$ {
#fastcgi_pass   B:80;
#     fastcgi_index index.php;
#     fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;
 #     include fastcgi_params;
           proxy_pass http://B:80;
            proxy_redirect off;
            proxy_set_header  Host  $host;
            proxy_set_header  X-Real-IP  $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;

是的,我知道fastcgi,但是我只想尝试这种方式,当我访问A:80 / index.php时,它下载的是php文件而不是执行该文件,这是什么问题?

问题已解决,请在nginx.conf中注释此行

 include /etc/nginx/conf.d/*.conf;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM