• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

关于think PHP部署nginx 配置

php 搞代码 4年前 (2022-01-22) 34次浏览 已收录 0个评论

这篇文章主要介绍了关于think PHP部署nginx 配置,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下

第一个问题:
Warning: require(): open_basedir restriction in effect. File(/mnt/wwwroot/admincc/thinkphp/start.php) is not within the allowed path(s): (/mnt/wwwroot/admincc/public/:/tmp/:/proc/) in /mnt/wwwroot/admincc/public/index.php on line 17Warning: require(/mnt/wwwroot/admincc/thinkphp/start.php): failed to open stream: Operation not permitted in /mnt/wwwroot/admincc/public/index.php on line 17Fatal error: require(): Failed opening required '/mnt/wwwroot/admincc/public/../thinkphp/start.php' (include_path='.:/usr/local/php/lib/php') in /mnt/wwwroot/admincc/public/index.php on line 17

这个是打开php错误提示后显示的错误信息(如果不打开提示,浏览器只会显示500错误,不便于排查。)

解决办法:

出现这种错误主要受fastcgi.conf中open_basedir参数控制,在我的配置文件中,这个参数的默认值是这样的:

fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

open_basedir参数的作用就是将php能打开的文件限制在特定的目录树中,默认的$document_root是nginx.conf中配置的/home/wwwroot/default目录,而我项目的目录是在/mnt/wwwroot/admincc/public下,由于项目目录没有包含在open_basedir中,因此会报如上的错,解决方法也就很简单了,将项目家目录加入即可。

fastcgi_param PHP_ADMIN_VALUE "open_basedir=/mnt/wwwroot:$doc本文来源gaodai#ma#com搞*!代#%^码$网!搞代gaodaima码ument_root/:/tmp/:/proc/";

PS:还有一种解决方法是直接把这个参数注释掉。

第二个问题:

错误提示:

scandir() has been disabled for security reasons

错误提示是说scandir函数因为安全原因被禁用了。

解决办法:

没错,就像它提示的这个函数默认在php.ini中是禁用的。

disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server

很明显,scandir被禁用了,解决方法也简单,把scandir删掉,重启php-fpm就好。

service php-fpm restart
第三个问题:

访问报404错误。

解决办法:

这个的原因在于nginx的配置有问题,在vhost/admincc.conf(站点虚拟主机的配置文件)中添加如下配置即可:

location / {            if (!-e $request_filename) {                rewrite  ^(.*)$  /index.php?s=/$1  last;                break;            }        }

由于ThinkPHP的入口文件是index.php,所以要重写下url。
保存配置,记得重启nginx。

相关推荐:

thinkphp部署到万网云服务器上报连接不上mysql

以上就是关于think PHP部署nginx 配置的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:关于think PHP部署nginx 配置

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址