&引用;“主脚本未知”;PHP

&引用;“主脚本未知”;PHP,php,nginx,Php,Nginx,我正在尝试在我的机器中使用PHP。我的nginx服务器运行的其他服务器很少 出于对如何使用PHP的好奇,我尝试安装PHPCLI和PHP5FPM 下面的nginx文件似乎可以工作,但是在前端我得到了错误“404”。当我检查错误日志时,我发现了错误 "2016/03/29 14:28:50 [error] 19752#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from up

我正在尝试在我的机器中使用PHP。我的nginx服务器运行的其他服务器很少

出于对如何使用PHP的好奇,我尝试安装PHPCLI和PHP5FPM

下面的nginx文件似乎可以工作,但是在前端我得到了错误“404”。当我检查错误日志时,我发现了错误

"2016/03/29 14:28:50 [error] 19752#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: ::1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "localhost:84"
所以我假设我的php5 fpm配置是错误的,或者我的nginx配置是错误的

这是我的nginx配置文件:

server {
listen 84 default_server;
listen [::]:84 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;

server_name localhost;
location / {
    index index.php index.html index.htm;
    root /home/sijan/personal/php_site;
}
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    #fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #fastcgi_pass unix:/var/run/php5-fpm.sock;
    #fastcgi_index index.php;
    #include fastcgi_params;
    }
}
从Digital Oceans开始,我遵循以下步骤,跳过几个步骤来安装MySQL,因为我将使用psql


非常感谢您提供的任何帮助。

我无法立即发现您的nginx配置有任何问题,但我发现PHP-FPM和nginx在配置时可能真的很不稳定。。。请改为尝试以下Nginx配置

server {
    listen 84 default_server;
    listen [::]:84 default_server ipv6only=on;
    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    server_name _;

    location / {
        index index.php index.html index.htm;
        root /home/sijan/personal/php_site;
    }

    location ~ \.php$ {
        try_files $uri =404;

        fastcgi_index                           index.php;
        fastcgi_pass                            unix:/var/run/php5-fpm.sock;
        fastcgi_connect_timeout                 10;
        fastcgi_send_timeout                    180;
        fastcgi_read_timeout                    180;
        fastcgi_buffer_size                     512k;
        fastcgi_buffers                         4       256k;
        fastcgi_busy_buffers_size               512k;
        fastcgi_temp_file_write_size            512k;
        fastcgi_intercept_errors                on;
        fastcgi_split_path_info                 ^(.+\.php)(/.*)$;
        fastcgi_keep_conn                       on;
        include fastcgi_params;
    }
}

另外,不要忘记,您的Nginx服务器正在配置中的端口84上侦听,而不是标准端口80。

读起来好像配置为索引文件的文件(
index.php
index.html
index.htm
)实际上不存在于配置的位置(
/home/sijan/personal/php\u site
)。实际上是index.php,我还尝试更改模式并授予了完全权限,但这并没有解决问题。您只需要工作进程对脚本具有读取权限,您应该再次删除这些“完全权限”。如果使用静态
index.html
文件成功安装,则nginx安装很可能正常。因此,您必须更深入地检查您的php设置是否实际可用。尝试在CLI上执行一些脚本以查看是否有效。我尝试使用配置,但我遇到了相同的问题。但是我尝试了其他的方法,在/php_站点中,以前我使用index.php,这根本不起作用,我将index.php删除到index.html并添加了简单的文本,它似乎起了作用。所以我想知道,这实际上是php5 fpm的错误吗。这是我原来的nginx配置的链接[link](),这是我的php fpm配置的链接[link]([)我真的需要关于修复这个问题的建议。很抱歉,我不知道如何在评论中正确使用这个链接。我试着遵循这个。出于兴趣,你正在使用什么版本的php?我正在ubuntu 14.04中使用PHP5.5.9。