再次:FastCGI发送到stderr:"主要脚本未知"从上游读取响应头

时间:2017-03-29 10:13:48

标签: php linux nginx fpm

所以我是第一个在Linux(Mint)上安装nginx + php的人。不在服务器上,而是在本地计算机上。我在标题中提到了一点。 我在SOF上经历了很多指南,文章和相关的静止,但结果总是一样的。据我所知,这种错误告诉nginx在查找fastcgi脚本时遇到问题。 我有一个用户作为root。

这是我的设置:

/ etc / nginx / common / php-fpm

fastcgi_pass    php-fpm7.0;

include fastcgi_params;
fastcgi_split_path_info                 ^(.+?\.php)(/.*)?$;
fastcgi_param   SCRIPT_FILENAME         $document_root$fastcgi_script_name;
fastcgi_param   PATH_TRANSLATED         $document_root$fastcgi_script_name;

set             $path_info              $fastcgi_path_info;
fastcgi_param   PATH_INFO               $path_info;

的/ etc / nginx的/位点可用/默认

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;
        # include common/upstream;

        root /home/raleksey/Downloads/business_encode_php5;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html index.php;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
#               include php-fpm;
        #       # With php7.0-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php7.0-fpm:
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
                deny all;
        }
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#       listen 80;
#       listen [::]:443;
#
#       server_name _test;
#
#       root /home/raleksey/Downloads/business_encode_php5;
#
#       index index.php index.html index.htm index.nginx-debian.html;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }
# }

有了这个设置,我收到了错误。如果我取消注释include php-fpm;,则Nginx服务器因nginx.serviceJob for nginx.service failed because the control process exited with error code.

而无法重启

好的,在那之后我寻找nginx状态。它说:

nginx: [emerg] open() "/etc/nginx/php-fpm" failed (2: No such file or directory) in /etc/nginx/sites-enabled/default:58
nginx: configuration file /etc/nginx/nginx.conf test failed

我该如何纠正?

UPD。我取得了一些进展。现在,浏览器不会找到" File not found",而是将页面下载为文件 - index.php。

0 个答案:

没有答案