linux of centos5

  • 2020-05-06 12:16:54
  • OfStack

The main content of the relevant configuration that has been effectively tested by zhiwen studio is as follows:


location ~ \.php(.*)$ {
 fastcgi_pass   unix:/tmp/php-cgi.sock;
 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;
 #include        fastcgi_params;
 include fcgi.conf;
}

A complete site configuration example:


log_format  v.lzw.me  '$remote_addr - $remote_user [$time_local] "$request" '
   '$status $body_bytes_sent "$http_referer" '
   '"$http_user_agent" $http_x_forwarded_for';
server {
 listen       80;
 server_name v.lzw.me;
 index index.html index.htm index.php default.html default.htm default.php;
 root  /www/v.lzw.me;
 # urlrewrite
 include v.lzw.me.conf;
 location ~ \.php(.*)$ {
  fastcgi_pass unix:/tmp/php-cgi.sock;
  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;
  #include        fastcgi_params;
  include fcgi.conf;
 }
 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
  expires 30d;
 }
 location ~ .*\.(js|css)?$ {
  expires 12h;
 }
 access_log  /wwwlogs/v.lzw.me.log  v.lzw.me;
}

Other method references (nginx et al., suitable for windows) :


location ~ \.php
{
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php;
 include fcgi.conf;
 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;
}


Related articles: