首页 > 网站 > 建站经验 > 正文

win2003下nginx 0.8.38 安装配置备忘

2019-11-02 16:16:57
字体:
来源:转载
供稿:网友
据说 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;
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表