nginx服务器配置

Linux6.2下所需软件包:Gcc,make,glibpcre-8.32.zipnginx-1.3.10.tar .gz配置域名:解压所需软件包,编译:unzip pcre-8.32.zipcd p

Linux6.2下

所需软件包:

Gcc,make,glib

pcre-8.32.zip

nginx-1.3.10.tar .gz

配置域名:

解压所需软件包,编译:

unzip pcre-8.32.zip

cd pcre-8.32

./configure

Make&&make install

tarzxvf nginx-1.3.10.tar.gz

cd nginx-1.3.10

./configure --with-http_stub_status_module --prefix=/opt/nginx Make&&make install

ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/

ls -l /usr/local/sbin/nginx

安装apache 源码包httpd-2.2.9.tar.gz ,启动apache 服务. 创建所需访问网页根目录以及访问文件:

mkdir -p /web/www/baidu/htdocs

mkdir -p /web/www/sina/htdocs

echo "www.baidu.com" > /web/www/baidu/htdocs/index.html echo "www.sina.com" > /web/www/sina/htdocs/index.html

查找libpcre.so.l 文件:

,

进入 /etc/ld.so.conf目录下,修改配置文件:

输入ldconfig 重新加载.

进入nginx 主配置文件.

在97行左右下输入配置文件:

server {

listen 80;

server_name www.baidu.com;

charset utf-8;

#access_log logs/baidu.access.log main;

location / {

root /web/www/baidu/htdocs;

index index.html index.htm;

}

}

server {

listen 80;

server_name www.sina.com;

charset utf-8;

#access_log logs/sina.access.log main;

location / {

root /web/www/sina/htdocs;

index index.html index.htm;

}

}

,

录入保存后,输入/opt/nginx/sbin/nginx -t进行验证成功. 继续输入/opt/nginx/sbin/nginx启动服务.

进行访问测试:

进入nginx 主配置文件.

修改配置文件,添加以下几行:

server {

listen

80;

,

server_name www.baidu.com;

charset utf-8;

access_log logs/baidu.access.log main;

location / {

root /web/www/baidu/htdocs;

index index.html index.htm;

location ~/status{

stub_status on;

access_log off;

}

}

}

查找到nginx 进程号,杀死进程。重新启动nginx 服务

重启输入www.baidu.com/status可进行访问状态统计

标签: