lnmp支持thinkphp

lnmp环境配置好后,直接把thinkphp放到相应的目录里进行解析,是不行的,thinkphp默认是用apache的,相应目录下有个.htacess是关于apache重写的,lnmp是用nginx,不适用,需要修改nginx 配置文件里的server{}里面的

server {
listen 80;
server_name domain;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

location / {

root /opt/nginx/html/domain/;
index index.php index.html index.htm ;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}

location ~ .+.php($|/) {
set $script $uri;
set $path_info "/";
if ($uri ~ "^(.+.php)(/.+)") {
set $script $1;
set $path_info $2;
}

root /opt/nginx/html/domain/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php?IF_REWRITE=1;
include /opt/nginx/conf/fastcgi_params;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root/$script;
fastcgi_param SCRIPT_NAME $script;
}

其中,在location / { }里面要指定root 的目录,网上看到有些人没写,结果就403了,同样的,location ~ .php$ {}里面也要添加root 位置

原文地址:https://www.cnblogs.com/2myroad/p/3842830.html