ThankPHP项目一般部署在lamp下一般没有问题,部署在lnmp就有点水土不服了,,,报404、ajax err,,,神马的
首先,修改下php.ini
更改: cgi.fix_pathinfo=1 doc_root=
然后,再需要修改下nginx的配置:
#方法一: jk409@ubuntu:/etc/nginx/sites-enabled$ sudo cat default [sudo] password for kkk: server { listen 80 default_server; root /data/www/t1; index index.php index.html index.htm; server_name localhost; location / { # try_files $uri /index.php$url; if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } } location ~ \.php/?.*$ { #root /var/www/html/website; fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; #加载Nginx默认"服务器环境变量"配置 include fastcgi.conf; #设置PATH_INFO并改写SCRIPT_FILENAME,SCRIPT_NAME服务器环境变量 set $fastcgi_script_name2 $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") { set $fastcgi_script_name2 $1; set $path_info $2; } fastcgi_param PATH_INFO $path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2; fastcgi_param SCRIPT_NAME $fastcgi_script_name2; } } #---------------------------------------------------------------------------------- #方法二: jk409@ubuntu:/etc/nginx/sites-enabled$ cat default server { listen 80 default_server; root /data/www/t1; index index.php index.html index.htm; server_name localhost; location / { index index.htm index.html index.php; #访问路径的文件不存在则重写URL转交给ThinkPHP处理 try_files $uri /index.php$uri; } location ~ .+\.php($|/) { #root /var/www/html/website; fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; #设置PATH_INFO,注意fastcgi_split_path_info已经自动改写了fastcgi_script_name变量, #后面不需要再改写SCRIPT_FILENAME,SCRIPT_NAME环境变量,所以必须在加载fastcgi.conf之前设置 fastcgi_split_path_info ^(.+\.php)(/.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; #加载Nginx默认"服务器环境变量"配置 include fastcgi.conf; 或(2者选一) include fastcgi_params; } } jk409@ubuntu:/etc/nginx/sites-enabled$
#url_mode=1模式 server { listen 50004; #server_name www.t1.com; root /var/www/html; index admin.php; #设置默认主页 location / { try_files $uri /index.php$uri; #index设置成默认的文件名 } location ~ .+\.php($|/) { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #设置默认的 fastcgi_split_path_info ^(.+\.php)(/.*)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi_params; } #或者下面的配置url_mode=0模式 location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } } location /var/www/html/ { if (!-e $request_filename){ rewrite ^/var/www/html/(.*)$ /var/www/html/index.php?s=$1 last; } } location ~ \.php$ { root /web/shangchi/www.t1.com; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PHP_VALUE "open_basedir=$document_root:/tmp/"; include fastcgi_params; } }