thinkphp lnmp 不能访问的问题

来源:互联网 发布:matlab数组循环赋值 编辑:程序博客网 时间:2024/05/21 14:33
之前 一直都没遇到 这两天遇到这种问题希望后面遇到这种问题的不要在入坑了
需要说明的是,环境配置成功后,网站已经可以访问了,由于我的根目录直接指定到public的,因此,public下的其它txt文件,ico图标都可以访问,我也新建了一个phpinfo.php文件,同样也可以访问。只有访问index.php的时候才出现“http error 500";

500:服务器内部错误,原因也很多!

一、首先我先检查环境

php和nginx都是启动正常,而且php和nginx日志都没有报任何的错误;从而说明不是php和nginx的原因;

二、重新修改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;

三、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配置才会生效。

三、再次访问index.php出现:

“scandir() has been disabled for security reasons”;


解决“scandir() has been disabled for security reasons”方法:

出现这个问题,那是因为php禁用了scandir()这个函数,我们只需要不禁用它即可。

可以通过查看phpinfo(),确认scandir()函数是否被禁用?下图则是禁用状态:
禁用scandir()


1、打开php.ini,一般默认位置是在/usr/local/php/etc/php.ini

2、找到“disable_functions”,并删除后面的“scandir”;
scandir
3、保存并退出,重启php-fpm即可!


五、再次去访问“http://www.wk139.cn/tp5/public/index.php”已经成功!


原创粉丝点击