lnmp1.5一键安装包

php版本是 7.1.18

tp5.1.16 本地环境运行正常

目前在centos 7.0的虚拟机上成功安装了以上软件。

访问500错误

 

1、加上错误日志,看一下错误信息

/usr/local/nginx/conf/yourdomain.com.conf文件中的 access_log 下面加上一段代码,文件名随意

error_log /home/wwwlogs/yourdomain.com_error.log notice;

访问一遍你的域名地址,重现一下错误,然后我们来看错误日志~如果没有文件,可能是没有写权限,手动创建后重试

错误类似于下面这样

[error] 31194#0: *21 FastCGI sent in stderr: "PHP message: PHP Warning:  require(): open_basedir restriction in effect.
File(/home/wwwroot/yourdomain.com/tp5/thinkphp/base.php) is not within the allowed path(s): (/home/wwwroot/yourdomain.com/tp5/public/:/tmp/:/proc/) 
in /home/wwwroot/yourdomain.com/tp5/public/index.php on line 16
PHP message: PHP Warning:  require(/home/wwwroot/yourdomain.com/tp5/thinkphp/base.php): 
failed to open stream: Operation not permitted in /home/wwwroot/yourdomain.com/tp5/public/index.php on line 16
PHP message: PHP Fatal error:  require(): Failed opening required '/home/wwwroot/yourdomain.com/tp5/public/../thinkphp/base.php'

看了一眼就盯上这个open_basedir玩意,它是用来设置防跨目录的,记得在文档上看到过,原文如下:

在 Thinkphp、codeigniter、Laravel 等框架下,网站目录一般是在 public 下,但是 public 下的程序要跨目录调用 public 上级目录下的文件

因为 LNMP 默认是不允许跨目录访问的,所以都是必须要将防跨目录访问的设置去掉,所以有时候这些框架类的程序提示 500 错误也可能是这个问题引起的

OK,因为安装的是 1.5 版本的,所以直接使用lnmp1.5/tools/目录下的./remove_open_basedir_restriction.sh进行移除

其他版本具体操作如下:

LNMP 1.4 上如果不想用防跨目录或者修改.user.ini的防跨目录的目录还需要将/usr/local/nginx/conf/fastcgi.conf里面的fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";在该行行前添加 # 或删除改行,需要重启 Nginx

LNMP 1.4 上就可以直接使用lnmp1.4/tools/目录下的./remove_open_basedir_restriction.sh进行移除

平滑重载一下 Nginx 服务,访问页面看到了熟悉的 ThinkPHP 初始页面,搞定正常可以访问

相关文章:

  • 2021-05-20
  • 2021-07-24
  • 2021-08-17
  • 2022-12-23
  • 2021-04-25
  • 2021-04-01
  • 2021-06-07
猜你喜欢
  • 2021-07-04
  • 2021-08-03
  • 2021-11-27
  • 2021-12-07
  • 2022-01-14
相关资源
相似解决方案