nginx windows下安装成功
第一步 下载nginx ,windows版本,解压保存在C:/nginx下( 用的1.0.3版)第二步 下载 php fast-cgi版本(我用的是 VC9 x86 Non Thread Safe),解压到C:/php下
第三步 把C:/php/php.ini-development重命名成C:/php/php.ini,找到#cgi.fix_pathinfo=1,把#号去掉
第四步修改C:/nginx/conf/nginx.conf
下面是我的简单配置:
#usernobody;
worker_processes1;
#error_loglogs/error.log;
#error_loglogs/error.lognotice;
#error_loglogs/error.loginfo;
#pid logs/nginx.pid;
events {
worker_connections1024;
}
http {
include mime.types;
default_typeapplication/octet-stream;
#log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_loglogs/access.logmain;
sendfile on;
#tcp_nopush on;
#keepalive_timeout0;
keepalive_timeout65;
#gzipon;
server {
listen 80;
server_namelocalhost;
#charset koi8-r;
#access_loglogs/host.access.logmain;
location / {
#root html; //此处为默认路径
root D:/public_html; //此处为我修改,要运行PHP程序的路径
indexindex.php index.html index.htm;//增加了 index.php
}
#error_page404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504/50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# root php;
#index index.php
#proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root D:/public_html; //运行的PHP程序路径
fastcgi_pass 127.0.0.1:9000;
fastcgi_indexindex.php; //默认首页程序
fastcgi_paramSCRIPT_FILENAME $document_root$fastcgi_script_name;//$document_root 指的是上面的 D:/public_html
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# denyall;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_namesomenamealiasanother.alias;
# location / {
# root html;
# indexindex.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_namelocalhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_keycert.key;
# ssl_session_timeout5m;
# ssl_protocolsSSLv2 SSLv3 TLSv1;
# ssl_ciphersALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# indexindex.html index.htm;
# }
#}
}
第五步 ,PHP以fast-cgi形式运行
在CMD下运行下面(路径可能有些不同)
C:\php>php-cgi.exe -b 127.0.0.1:9000 -c C:/php/php.ini
第六步点击运行 nginx.exe,运行nginx
第七步浏览器中输入 localhost/index.php,就运行D:/public_html/index.php这个程序了
页:
[1]