【问题标题】:nginx pass php request to a php-apache server , but download instead of executing the php filesnginx 将 php 请求传递给 php-apache 服务器,但下载而不是执行 php 文件
【发布时间】:2016-08-01 17:23:57
【问题描述】:

我设置了2台服务器,一台是nginx,80端口。 B 服务器是 php 和 apache ,端口 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文件而不是执行它,这是什么问题?

【问题讨论】:

    标签: php apache nginx


    【解决方案1】:

    问题解决了,在 nginx.conf 中注释掉这一行

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-05
      • 1970-01-01
      • 1970-01-01
      • 2011-12-30
      • 1970-01-01
      • 2017-12-21
      • 2019-08-09
      • 2019-07-21
      相关资源
      最近更新 更多