linux(centos5.5)/windows下nginx开启phpinfo模式功能的配置方法分享

时间:2021-05-19

经过志文工作室测试有效的相关配置主要内容如下:
复制代码 代码如下:
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;
}

一个完整的站点配置示例:

复制代码 代码如下:
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_passunix:/tmp/php-cgi.sock;
fastcgi_indexindex.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)$ {
expires30d;
}

location ~ .*\.(js|css)?$ {
expires12h;
}

access_log /wwwlogs/v.lzw.me.log v.lzw.me;
}

其他方法参考(适合windows下的nginx等):

复制代码 代码如下:
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;
}

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章