360°网站管家_运维学院_提供最新最全的服务器运维视频教程与网站维护视频教程
标题:
ThinkPHP框架下在Nginx服务器的配置问题
[打印本页]
作者:
360网站管家
时间:
2015-10-13 12:44
标题:
ThinkPHP框架下在Nginx服务器的配置问题
前几天看到同事在我的机器上在
nginx
服务器下配置一个本地访问的网站,而那个站是以用ThinkPHP框架为基础构建的。结果按照最开始的配置方法(就是
nginx
默认的配置方法)配置这个站,怎么多访问不了。。。难道是这个服务器不支持ThinkPHP框架。。在网上查了查资料发现果然用了thinkphp框架的网站在该服务器下不能简单的按照它默认的方式去配置需要在配置里面加一些代码,下面是nginx服务器下两种情况的配置
没有用ThinkPHP框架在nginx中的配置:
server {
listen 80;
server_name zx.server110.com;
#charsetkoi8-r;
#access_log logs/host.access.log main;
location / {
root d:/webroot/zx.server110.com;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirectserver error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location =/50x.html {
root html;
}
# proxy the PHPscripts to Apache listening on 127.0.0.1:80
#
#location ~\.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHPscripts to FastCGI server listening on 127.0.0.1:9000
#
location ~\.php$ {
root d:/webroot/zx.server110.com;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to.htaccess files, if Apache's document root
# concurs withnginx's one
#
#location ~/\.ht {
# deny all;
#}
}
用ThinkPHP框架在nginx中的配置:
server {
listen 80;
server_name user.server110.com;
#charsetkoi8-r;
#access_log logs/host.access.log main;
location / {
root d:/webroot/user.server110.com;
index index.php;
if (!-e $request_filename)
{
rewrite ^/user.server110.com/(.*)$ /user.server110.com/index.php/$1 last;
break;
}
}
#error_page 404 /404.html;
# redirectserver error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location =/50x.html {
root html;
}
# proxy the PHPscripts to Apache listening on 127.0.0.1:80
#
#location ~\.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHPscripts to FastCGI server listening on 127.0.0.1:9000
#
location ~.+\.php($|/)
{
root d:/webroot/user.server110.com;
set $script $uri;
set $path_info "/";
if ($uri ~ "^(.+\.php)(/.+)")
{
set $script $1;
set $path_info $2;
}
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
fastcgi_index index.php?IF_REWRITE=1;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root/$script;
fastcgi_param SCRIPT_NAME $script;
}
# deny access to.htaccess files, if Apache's document root
# concurs withnginx's one
#
#location ~/\.ht {
# deny all;
#}
}
这两种配置中不同的地方就是新加的代码。
欢迎光临 360°网站管家_运维学院_提供最新最全的服务器运维视频教程与网站维护视频教程 (http://bbs.360wzgj.com/)
Powered by Discuz! X3.2