[root@rhel6u3-2 ~]# uname –r //查看系统内核版本号
2.6.32-279.el6.i686
[root@rhel6u3-2 ~]# cat /etc/redhat-release //查看系统版本号
Red Hat Enterprise Linux Server release 6.3 (Santiago)
二、编辑虚拟主机配置文件
[root@rhel6u3-7 ~]# vim /usr/local/nginx/conf/nginx.conf //主配置文件中http字段中添加以下语句,将虚拟主机的配置文件指向www1.rsyslog.org
include /usr/local/nginx/server/www1.rsyslog.org;
[root@rhel6u3-7 ~]# vim /usr/local/nginx/server/www1.rsyslog.org
server {
listen 80; //监听端口为80
server_name www1.rsyslog.org; //虚拟主机网址
location / {
root sites/www1; //虚拟主机网站根目录
index index.html index.htm; //虚拟主机首页
auth_basic "secret"; //虚拟主机认证命名
auth_basic_user_file /usr/local/nginx/passwd.db; //虚拟主机用户名密码认证数据库
}
location /status {
stub_status on; //开启网站监控状态
access_log /usr/local/nginx/logs/www1_status.log; //监控日志
auth_basic "NginxStatus"; }
}
[root@rhel6u3-7 ~]# /etc/rc.d/init.d/nginx reload //平滑重启nginx服务
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Reloading nginx: [ OK ]
五、DNS服务器上添加www1 A记录
www1 A 192.168.100.107 六、通过IE访问www1.rsyslog.org进行测试。
别忘了将网卡首选DNS指向192.168.100.102