win2003下nginx 0.8.38 安装配置备忘

2019-10-17 21:24:44于海丽

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /.ht {
# deny all;
#}
}

# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}

# HTTPS server
#
#server {
# listen 443;
# server_name localhost;

# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_timeout 5m;

# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}
}

这时,在本机上打开浏览器,浏览 http://localhost,可以看到信息“Welcome to nginx!”,内容来自 html 下的 index.html 文件。

为了真正与 PHP 一起协同工作,还必须运行 PHP 的 php-cgi.exe 程序。方法是,在命令窗口内,切换到 php-cgl.exe 所在文件夹,运行下,即 C:php-5.3.2-Win32-VC6-x86,运行 php-cgi.exe -b 127.0.0.1:9000 命令,即:

C:php-5.3.2-Win32-VC6-x86〉php-cgi.exe -b 127.0.0.1:9000

这里的127.0.0.1:9000 就是我们在 nginx.conf 文件中配置的那个,端口号一定要相同。

nginx.exe 与 php-cgi.exe 两条命令运行的前后顺序对 PHP 文件的解析没有影响。

这时,我们在根目录下放一个 xxx.php 文件,在浏览器地址栏里面输入 http://localhost/xxx.php,应该看到结果。建议文件内容为:

<?php
phpinfo();
?>

我们可以看到 PHP 环境的很多有用的信息。

nginx 还可以配置实现反向代理、多个虚拟主机、url重定向等功能。