Nginx在nginx.org站点下载
fastcgi_params nginx.conf vhosts.conf需要配置
nginx\conf/fastcgi_params
配置:
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $host;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
nginx\conf/nginx.conf 配置:
worker_processes 1;
error_log logs/error.log warn;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
#
# core
#
client_header_buffer_size 8k;
default_type text/plain;
keepalive_disable msie6 safari;
keepalive_requests 500;
keepalive_timeout 50s;
log_not_found off;
merge_slashes off;
msie_padding off;
sendfile on;
server_tokens off;
tcp_nopush on;
include mime.types;
#
# access
# auth_basic
#
#
# autoindex
#
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
#
# headers
# limit_conn
# limit_req
# rewrite
#
#
# gzip
#
gzip on;
gzip_comp_level 1;
gzip_disable "MSIE\s[1-7]";
gzip_types text/css text/xml application/x-javascript text/plain;
gzip_vary on;
#
# index
#
index index.php index.html index.htm
#
# log
#
access_log off;
#
# proxy
#
proxy_cache_path temp/cache_temp levels=1:1:1 keys_zone=ngxcdn:100m;
proxy_temp_path temp/proxy_temp 1 1 1;
proxy_connect_timeout 1s;
#
# vhosts
#
include vhosts.conf;
}
Nginx/conf/vhosts.conf 虚拟机配置
server {
listen 80;
access_log off;
location / {
root "D:/projects/localhost/www";
}
location /server-status {
allow all;
stub_status on;
}
location ~ \.php$ {
root "D:/projects/localhost/www";
include fastcgi_params;
}
server_name _;
}
#renzhe
server {
listen 80;
access_log off;
location / {
root "D:/projects/gamexbox/tech/zhangkg/v0.9/www.renzhe.com/www";
include D:/projects/gamexbox/tech/zhangkg/v0.9/www.renzhe.com/www/rewrite.conf;
}
location ~ \.php$ {
root "D:/projects/gamexbox/tech/zhangkg/v0.9/www.renzhe.com/www";
include fastcgi_params;
}
server_name www.renzhe.com box.www.renzhe.com 多个子站点;
error_log "D:/projects/gamexbox/tech/zhangkg/v0.9/www.renzhe.com/log/error.log";
access_log "D:/projects/gamexbox/tech/zhangkg/v0.9/www.renzhe.com/log/access.log" combined;
}
Php.ini 下修改
;cgi.rfc2616_headers = 0
改为
;cgi.rfc2616_headers = 1
Nginx 启动方法
Nginx -t
Nginx -s reload
Php要以cgi 模式运行
命令行中
Php/bin php-cgin -b 127.0.0.1:9000