1、概述
thinkphp 不能直接在nginx上使用 因为要用pathinfo。 云云总总查了好多,也没配好。
2、配置
2.1 修改PHP.INI 支持 PHPINOF
PHP配置文件:/usr/local/php/etc/php.ini
更改php.ini
找到:cgi.fix_pathinfo=0
更改为:cgi.fix_pathinfo=1
2.2 修改nginx配置文件
配置文件路径查询:nginx -t 显示出路径
server
{
listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;
server_name www.lnmp.org;
index index.html index.htm index.php;
root /home/wwwroot/default;
#error_page 404 /404.html;
#include enable-php.conf;
include enable-php-pathinfo.conf;
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1;
}
}
location ~ \.php {
#fastcgi_pass remote_php_ip:9000;
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi_params;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/access.log;
}
include vhost/*.conf;
}
3、重启
lnmp restart