nginx完美支持thinkphp
apache对thinkphp完美支持。但是换到nginx服务器下就各种打不开。
下边是nginx 的配置。直接粘贴(配置文件路径一般在/etc/nginx/文件夹下)下来就可以了并修改server_name 域名 和 root 目录,然后如果需要模式2(隐藏index.php) 在thinkphp的配置文件中添加 'URL_MODEL' => '2'。
下面是我的配置 供大家参考:
server { listen 80; server_name www.nice513.com ;#填写你的域名 index index.html index.htm index.php;#默认打开页面 root "\www.nice513.com\Public";#你的index.php路径 location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } location / { #如果是二级目录就用 rewrite ^/文件夹名称/(.*)$ /index.php?s=/$1 last;) if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } }
这样就可以让nginx完美支持thinkphp了。
喜欢(2)