thinkphp lnmp 不能訪問的問題

以前 一直都沒遇到 這兩天遇到這種問題但願後面遇到這種問題的不要在入坑了
須要說明的是,環境配置成功後,網站已經能夠訪問了,因爲個人根目錄直接指定到public的,所以,public下的其它txt文件,ico圖標均可以訪問,我也新建了一個phpinfo.php文件,一樣也能夠訪問。只有訪問index.php的時候纔出現「http error 500";

500:服務器內部錯誤,緣由也不少!

1、首先我先檢查環境

php和nginx都是啓動正常,並且php和nginx日誌都沒有報任何的錯誤;從而說明不是php和nginx的緣由;

2、從新修改nginx.conf根目錄位置:

記住,這裏修改時,必定不要把根目錄定到public下,由於有時候直接定到public也有一些問題,具體爲何我也不知道;經驗吧!
server
{
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
server_name _;
index index.html index.htm index.php;
root /home/wwwroot/www.wk139.cn;
......


注意:必定要重啓nginx;

3、php.ini 開啓錯誤調試

因爲個人日誌不報任何錯誤,並且打開index.php也不報任何錯誤,只報500,這怎麼能行?不知道錯誤又如何解決問題呢?

打開php.ini,在合適位置添加「display_errors:On」
display_errors:On 
; display_errors
; Default Value: On
; Development Value: On
; Production Value: Off

注意:必定要重啓php,php.ini配置纔會生效。

3、再次訪問index.php出現:
「scandir() has been disabled for security reasons」;
解決「scandir() has been disabled for security reasons」方法:

出現這個問題,那是由於php禁用了scandir()這個函數,咱們只須要不由用它便可。

能夠經過查看phpinfo(),確認scandir()函數是否被禁用?下圖則是禁用狀態:
禁用scandir()

一、打開php.ini,通常默認位置是在/usr/local/php/etc/php.ini

二、找到「disable_functions」,並刪除後面的「scandir」;
scandir
三、保存並退出,重啓php-fpm便可!

5、再次去訪問「http://www.wk139.cn/tp5/public/index.php」已經成功!
php

相關文章
相關標籤/搜索