yuanqiao 发表于 2015-8-21 11:11:41

lnmp + codeiniter / thinkphp

  第一,nginx不支持.htaccess,需要自己在nginx.conf里面修正URL。
  第二,首先选择try_files,而不是rewrite,避免使用大量的if。nginx官网指出,if语句是应当尽量避免的。
  第三,nginx没有PATHINFO,需要自己模拟一个出来。
  
  综上,nginx.conf应当以类似如下形式使用:
  server
{
listen 80;
server_name yourhost;
index index.html index.htm index.php;
root /home/wwwroot/yourdomain/
  #注意,用的是try_files,而不是rewrite+if
try_files $uri $uri/ /index.php/$uri;

location ~ ^(.+\.php)(.*)$
{
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;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass unix:/tmp/php-cgi.sock;
include fcgi.conf;
}
  location /status {
stub_status on;
access_log off;
}
  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
  location ~ .*\.(js|css)?$
{
expires 12h;
}
  参考:http://www.yamlan.net/archives/250.html
页: [1]
查看完整版本: lnmp + codeiniter / thinkphp