全国统一热线:
028-86758058
18980748058
购买流程
付款方式
常见问题
在线提问
续租服务
购物车(
0
件)
用户名:
密 码:
记住
首 页
HOME
域名注册
DOMAIN
虚拟主机
WEB HOST
成品网站超市
AUTO Site
VPS主机
VPS SERVER
云 主 机
CLOUD HOST
租用托管
SERVER
海外主机
HK HOST
代理专区
AGENT
客服中心
SERVICE
IDC资讯
SERVICE
欢迎光临天府快车,我们将竭诚为您提供最优质的服务!
中文域名
域名转入
域名转出
DNS管理
动态域名
获取域名证书
域名停放
域名过户
集群主机
双线主机
基本主机
港台主机
论坛主机
Linux主机
Vip合租主机
超G型主机
ASP.net主机
Java主机
智能建站主机
网店主机
美国主机
数据库
成品网站超市
智能建站主机
集群VPS主机
国内VPS主机
香港VPS主机
美国VPS主机
云主机介绍
云主机购买
服务器租用
主机托管
常见问题
香港主机
港台主机
美国主机
国内免备案
步骤流程
代理级别
代理合同
代理模式
代理优势
在线申请
产品列表
常见问题
代理商分布图
常见问题
有问必答
跟踪提问
购买流程
产品价格
付款方式
常用软件
网站备案
续租服务
汇款确认
相关文档
联系我们
IDC资讯
行业资讯
网站运营
站长百科
IDC新闻
域名资讯
云计算
虚拟主机
您当前的位置:
首页
>
站长百科
>
服务器技术
win2003下nginx 0.8.38 安装配置备忘
时间:2015-01-18 来源:互联网 作者:佚名
据说 nginx 是这几年来 Web
服务器
的后起之秀,是“Apache杀手”,由俄罗斯程序员编写。是一个轻量级的 Web 服务器,也是据说,占用资源少,高并发,在某些情况下,效率是 Apache 的 10 倍。国内外很多大型门户站都在用。
经不住蛊惑,决定在 Windows Server 2003 下安装试用一下,并与 PHP 进行集成。
截至 2010 年 5 月底,nginx 的最新版本是 0.8.38,可以到 http://www.nginx.org/ 下载。
解压 PHP 到 C:\php-5.3.2-Win32-VC6-x86\,正确配置 php.ini 文件。
直接解压下载的 nginx-0.8.38.zip 文件到 C:\nginx-0.8.38\,文件夹结构:
conf\
contrib\
docs\
html\
logs\
temp\
nginx.exe
双击运行nginx.exe文件,nginx 就开始提供服务。
html\ 文件夹为网站默认根目录。
conf\ 放置 nginx 配置有关的文件。配置文件 nginx.conf 内容如下(#号打头的语句被注释掉了,可以参考):
server {……} 部分配制了 nginx 的 http 服务的端口(默认为80)、域名、字符集、根文件夹、首页文件等内容。
其中以下部分配置 nginx 与 PHP 以 fastcgi 方式进行集成,“C:/nginx-0.8.38/html”表示网站的根文件夹:
.
代码如下:
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME C:/nginx-0.8.38/html$fastcgi_script_name;
include fastcgi_params;
}
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] “$request“ '
# '$status $body_bytes_sent “$http_referer“ '
# '“$http_user_agent“ “$http_x_forwarded_for“';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
autoindex on;
}
#error_page 404 /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$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME C:/nginx-0.8.38/html$fastcgi_script_name;
include fastcgi_params;
}
# 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重定向等功能。
来顶一下
返回首页
推荐资讯
【图文教程】dede织梦网站后台如何
对于新手站长可能不了解,dede织梦后台是如何发文章的。下面
2014站长圈十大事件:PR已死 移动算
2014年即将过去,虽然站长圈相比过去几年稍显沉寂,但&ldquo
相关文章
无相关信息
栏目更新
栏目热门
返回首页
关于我们
联系我们
付款方式
价格总览
资讯中心
友情链接
媒体关注
有问必答
投诉建议
网站备案
《中华人民共和国增值电信业务经营许可证》编号:川B2-20080058号
官方网址:
www.tfkc.cn
天府快车
Copyright © 2002~2015
天府快车
版权所有
电话总机:
028-86758058
(50线) 传真:
028-86758058