Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

Tp5在nginx下如何配置conf文件应对opendir #510

Open
lovearthhome opened this issue Oct 15, 2017 · 0 comments
Open

Tp5在nginx下如何配置conf文件应对opendir #510

lovearthhome opened this issue Oct 15, 2017 · 0 comments

Comments

@lovearthhome
Copy link

lovearthhome commented Oct 15, 2017

刚刚建立的tp网站,打开首页是这个样子
image

查询了一番,说是opendir错误。参考https://www.kancloud.cn/manual/thinkphp5/336757后修改nginx配置文件如下,就增加了fastcgi_param PHP_VALUE这一行。
然而,打开网站还是上面的样子。
大牛大神帮我看一下,这里面哪里设置错了。
`
server
{
listen 80;
server_name admin.mydomain.com;
#index index.html index.htm index.php default.html default.htm default.php;
root /var/www/html/admin.mydomain.com/public;
location / {
index index.htm index.html index.php;
if ( -f $request_filename) {
break;
}
#访问路径的文件不存在则重写URL转交给ThinkPHP处理
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
}
}
location ~ [^/].php(/|$) {
set $path_info "";
#定义变量 $real_script_name,用于存放真实地址
set $real_script_name $fastcgi_script_name;
#如果地址与引号内的正则表达式匹配
if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$") {
#将文件地址赋值给变量 $real_script_name
set $real_script_name $1;
#将文件地址后的参数赋值给变量 $path_info
set $path_info $2;
}
#配置fastcgi的一些参数
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;

		fastcgi_param PHP_VALUE "open_basedir=/var/www/html/admin.**mydomain**.com/:/tmp/:/proc/";
		include  fastcgi_params;
	}

}

`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant