可以';不要使用nginx和php7加载任何PHP文件或在日志中看到任何错误


Can't load any PHP file or see any error in the logs using nginx and php7

我最近刚刚在服务器上安装了Nginx 1.8和PHP7,试图让它为我的应用程序服务。

当我将webroot文件夹索引文件设置为只返回Hey的HTML文件时,我可以看到加载了该文本的页面。

然而,当我尝试用index.php文件替换index.html文件时,我只看到一个空白页面,没有出现任何错误。

我试图查看/var/log/nginx/access.log/var/log/nginx/error.log以及我的站点错误日志:/var/log/nginx/my-website-error.log。在那里找不到任何错误。

我试着查看/var/log/php7.0-fpm.log上的PHP7.0-FPM错误日志,但也没有。

我确保编辑了我的/etc/php/7.0/fpm/php.ini文件并设置了display_erorrs = Onerror_reporting=E_ALL

我仍然看不到任何错误,也无法执行任何PHP代码。

我的Nginx配置文件将php执行传递给FPM,它看起来像:

location ~ '.php$ {
        fastcgi_split_path_info ^(.+'.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
}

知道发生了什么事吗?

在包含params文件之前尝试添加fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;。这个参数定义php应该执行的脚本。