关于支持pathinfo
这几天想吧thinkphp项目转移到lnmp上运行。发现需要pathinfo,网上查了很多教程(包括论坛的教程),还是没有解决问题。望上天赐我大神,搭救搭救疑问:在网上说没有配置好pathinfo最多就是502 ,而我一直是404,是不是有其他问题,付截图
(非pathinfo)
http://sisebst-sisebst.stor.sinaapp.com/QQ%E5%9B%BE%E7%89%8720140718172605.jpg
(使用后)
http://sisebst-sisebst.stor.sinaapp.com/QQ%E5%9B%BE%E7%89%8720140718172642.jpg 自顶一下
:lol 大神赶紧出现 1.1 启用pathinfo方法在更新纪录里有http://lnmp.org/changelog.html
其他版本论坛也写过了 军哥,我按照更新说说的配置了,还是不行,求帮助:Q附上nginx的配置:
userwww www;
worker_processes auto;
error_log/home/wwwlogs/nginx_error.logcrit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
default_typeapplication/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
gzip on;
gzip_min_length1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE \.";
#limit_conn_zone $binary_remote_addr zone=perip:10m;
##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.
server_tokens off;
#log format
log_formataccess'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
server
{
listen 81 default;
#listen [::]:80 default ipv6only=on;
server_name www.lnmp.org;
index index.html index.htm index.php;
root/home/wwwroot/default;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
#try_files $uri =404;
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
include pathinfo.conf;
}
location /nginx_status {
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log/home/wwwlogs/access.logaccess;
}
include vhost/*.conf;
} 不用改什么,thinkphp 用这个安装包很方便啊..
server
{
listen 80;
#listen [::]:80;
server_name www.sb.com sb.com;
if ($host != 'www.sb.com' ) {
rewrite ^/(.*)$ http://www.sb.com/$1 permanent;
}
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/www.sb.com;
include other.conf;
#error_page 404 /404.html;
location / {
if (!-e $request_filename) {
rewrite^(.*)$/index.php?s=$1last;
}
}
location ~ [^/].php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*.(js|css)?$
{
expires 12h;
}
access_log/home/wwwlogs/www.sb.com.logaccess;
} 添加vhost的时候 pathinfo 选 other
回复 1# 的帖子
回复楼主,我也是在用 军哥的 lnmp包,关于 thinkphp 的 pathinfo 让nginx 可以支持,
你可以新建一个 vhost,我将我的 贴给你看,你看着位置 进行改动,一定能正常访问的!
分割线下面,均是新建的vhost,默认路径是 /home/wwwroot/ruan
==================================================
server
{
listen 7899;
server_name 119.146.203.247;
index index.html index.htm index.php;
root/home/wwwroot;
location /ruan {
index index.php;
if (!-e $request_filename) {
rewrite ^/ruan/(.*)$ /ruan/index.php/$1 last;
break;
}
}
location ~ .+.php($|/) {
set $script $uri;
set $path_info "/";
if ($uri ~ "^(.+.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_index index.php?IF_REWRITE=1;
include fcgi.conf;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME /home/wwwroot$fastcgi_script_name;
include fastcgi_params;
}
}
===================================================================
分割线 结束
然后 - 更改php.ini
#vim /usr/local/php/etc/php.ini
找到:cgi.fix_pathinfo
更改为:cgi.fix_pathinfo=1
最后,记得重启 nginx 和 php-fpm 模块
==============================================
对于thinkphp框架项目的访问格式有多种,其中pathinfo是默认的基本访问格式,
格式为:http://hostname:port/index.php/模块名/action名/参数1/参数1的值/
pathinfo其实就是一个参数,
可以通过$_SERVER['PATH_INFO']获得,
thinkphp框架通过解析它来找到对应的模块和方法。
apache服务器默认是支持pathinfo的,但是nginx服务器默认不支持这种格式
谢谢
[ 本帖最后由 imacintosh 于 2014-7-19 15:18 编辑 ]
页:
[1]