无法使用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文件时,我只看到一个空白页面,没有错误是spat。
我试着查看/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 = On和error_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;
}
知道发生了什么事吗?
I've just recently installed Nginx 1.8 and PHP7 on my server trying to make it serve my application.
When I make my webroot folder index file an HTML file which just returns Hey, then I can see the page loaded with that text.
However, when I try to replace that index.html file with index.php file I just see a blank page and no errors being spat.
I tried to look into /var/log/nginx/access.log and /var/log/nginx/error.log as-well as my site error log: /var/log/nginx/my-website-error.log. Couldn't find any error there.
I tried to maybe look at the PHP7.0-FPM error log found at /var/log/php7.0-fpm.log but nothing there as-well.
I made sure to edit my /etc/php/7.0/fpm/php.ini file and set display_erorrs = On and error_reporting=E_ALL.
I still can't see any error and I can't execute any PHP code.
My Nginx config file which passes the php execution to FPM looks like:
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
Any idea what's going on?
原文:https://stackoverflow.com/questions/34523103
更新时间:2019-10-13 23:13
最满意答案
尝试添加fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 在包含params文件之前。 此参数定义php应执行的脚本。
Try to add fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; before including the params file. This parameter defines the script that php should execute.
2015-12-31
相关问答
尝试添加fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 在包含params文件之前。 此参数定义php应执行的脚本。 Try to add fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; before including the params file. This parameter defines the script that
...
尝试改变: log_errors on
error_log /home/account/public_html/error.log
至 log_errors = on
error_log = /home/account/public_html/error.log
接下来,在脚本顶部附近,执行以下操作: echo php_ini_loaded_file(); // to make sure that you're editing the right php.ini
echo ini_get('
...
所有这些扩展都可以在Alpine存储库中使用,那么为什么要让您的生活更加艰难并直接从PECL安装它们? 使用apk安装它们。 PHP7,Redis的 PHP7-的OAuth PHP7-memcached的 php7-mongodb (目前仅在测试库中) PHP7-的OpenSSL 请注意,这些软件包是在Alpine v3.7(最新的稳定版本)中,我还没有检查它们是否也在旧版本中可用。 当然,这些软件包会安装extension=.so配置文件,因此不要手动将其添加到php.ini 。 ap
...
添加proxy_set_header Host $host; 到第一个nginx。 否则,您的上游获取test_rack而不是原始主机名, $sub变量为空。 Add proxy_set_header Host $host; to first nginx. Otherwise your upstreams get test_rack instead of original hostname and $sub variable is empty.
这是json_decode的绝对正常行为。 如果给定的字符串不是有效的JSON字符串,它将抛出此异常。 正如您已经提到的那样,一个空字符串也不是有效的JSON字符串。 json_decode('Hello') // invalid
json_decode("Hello") //invalid
但: json_decode("'Hello'") // valid JSON string
自PHP7以来,空字符串将引发异常! “使用第一个参数调用json_decode等于空的PHP字符串或赋值为字
...
文件/etc/php/7.0/cli/php.ini用于PHP运行槽命令行。 在/etc/php/7.0/fpm中应该有一个php.ini,其中包含PHP-FPM的设置。 编辑完成后,使用此命令重新启动php-fpm service php7.0-fpm restart
The file /etc/php/7.0/cli/php.ini is for PHP-running trough commandline. There should a php.ini in /etc/php/7.0/fp
...
我发现这个问题,在我使用的代码的某处出现了一个自定义异常,这个异常在默认情况下启动了一个500 http错误的头文件,但是该头文件在异常启动后没有被杀死,所以很难找到它: public function __construct($message = "Critical error", $code = 500, Exception $previous = Null) {
parent::__construct($message, $code, $previous);
if($th
...
如果你的操作系统是UBUNTU 安装适用于Linux的unixODBC驱动程序管理器和Microsoft ODBC驱动程序 wget https://raw.githubusercontent.com/Microsoft/msphpsql/PHP-7.0-Linux/ODBC%20install%20scripts/installodbc_ubuntu.sh
运行安装程序 sh installodbc_ubuntu.sh
安装PHP依赖关系 apt-get install php-pear p
...
升级到PHP 7后我遇到了同样的问题。 将PhpMyAdmin升级到上一版本修复了该问题。 I faced the same problem after upgrading to PHP 7. Upgrading PhpMyAdmin to the last version fixed the issue.
PHP向日志文件,syslog(3)或stderr报告错误,具体取决于是否以及如何设置error_log 。 请参阅此文档了解详细信息 nginx将记录它通过FastCGI stderr流接收的消息。 所以,这并不是一种奇怪的行为。 PHP reports errors to a logfile, syslog(3) or stderr, depending on if and how error_log is set. See this document for details. nginx w
...