您好,欢迎访问一九零五行业门户网

关于think PHP部署nginx 配置

这篇文章主要介绍了关于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:$document_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 配置的详细内容。
其它类似信息

推荐信息