繁体   English   中英

Nginx和php-fpm下载php文件而不是执行

[英]Nginx and php-fpm downloading php file instead of executing

我被发疯了。 也许有人可以找到为什么这行不通。

使用Nginx 1.10.0并尝试在我的实验服务器ubuntu 16.04上以pagespeed安装Worpress

/usr/local/nginx/conf/nginx.conf

user  henri:www-data;
worker_processes  1;

error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

http {
    include       mime.types;

#    default_type  application/octet-stream;
     default_type text/html;
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

}

纳米/ etc / nginx / sites-available / default

server {
        listen   80; ## listen for ipv4; this line is default and implied
        listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

        root /var/www/www.xxxxxxx.com/public_html;
        index index.php index.html index.htm;

#       server_name localhost;

        location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
        }

        location / {
                 try_files $uri $uri/ /index.php$is_args$args;
        }

 location ~ \.php$ {

        fastcgi_pass unix:/var/run/php7-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     }
}

在我的/etc/php/7.0/fpm/pool.d/www.conf中

listen = /var/run/php7-fpm.sock;
...

套接字位于相应的目录中。

我试过了:

  1. 清空浏览器缓存
  2. 重启服务器/ nginx / php-fpm

ps aux | grep php-fpm

root      4593  0.0  0.7 362588 30592 ?        Ss   22:50   0:00 php-fpm: master process (/etc/php/7.0/fpm/php-fp.conf)
henri     4595  0.0  0.1 362588  6124 ?        S    22:50   0:00 php-fpm: pool www
henri     4596  0.0  0.1 362588  6124 ?        S    22:50   0:00 php-fpm: pool www
henri     4769  0.0  0.0  14224   968 pts/0    R+   23:15   0:00 grep --color=auto php-fpm

在我的php7.0-fpm.log / Nginx error.log / access.log中没有异常

文件仍在下载而不是执行。 我想念什么?

好吧,那太愚蠢了! 希望这不会发生在其他任何人身上! 我一直在配置错误的nginx文件!!!!

我通过输入nginx -V(大写V)来理解这一点...它将为您提供所有nginx文件的正确路径...请不要以为您正在处理的文件是正确的文件!

解决了!

暂无
暂无

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

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