标签:httpd基本应用
建立httpd服务,通过httpd-2.2和httpd2.4实现:
1、提供基于名称的虚拟主机www1、www2,有单独的错误日志和访问日志
2、通过www1的/server-status的状态信息,且允许tom用户访问
3、www2不允许192.168.0.0/24网络中的任意主机访问
4、为第二个虚拟主机提供https服务
一、在CentOS上通过httpd-2.2实现以上要求
1、安装httpd-2.2的rpm包,
[root@localhost wordpress]# yum -y install httpd
[root@localhost wordpress]# rpm -qa |grep httpd
httpd-tools-2.2.15-45.el6.centos.x86_64
httpd-2.2.15-45.el6.centos.x86_64
2、修改httpd的配置文件,新建两个虚拟主机
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
ServerName www1.qq.com:80 找到此行,把前面的#号取消
NameVirtualHost 172.16.18.5:80 把这前面的#号取消,开启虚拟主机
创建第一个虚拟主机配置文件
[root@localhost conf.d]# vim vhost1.conf
创建第二个虚拟主机配置文件
[root@localhost conf.d]# vim vhost2.conf
检查配置文件,并启动httpd服务
[root@localhost conf.d]# httpd -t
Syntax OK
[root@localhost conf.d]# service httpd restart
停止 httpd: [确定]
正在启动 httpd: [确定]
3、创建html资源文件
[root@localhost www1]# vim index.html
<h1>www1.site</h1>
[root@localhost www2]# vim index.html
<h1>www2.site</h1>
创建访问server-status的账户 tom
[root@localhost logs]# htpasswd -c -m /etc/httpd/conf/.htpasswd tom
4、修改hosts文件并进行测试
访问www1虚拟主机,能够访问页面
访问www2虚拟主机,能够访问页面
通过www1访问/server-status,需要身份验证
输入用户名tom和密码,能够访问状态信息
Server Version: Apache/2.2.15 (Unix) DAV/2
Server Built: Jul 24 2015 11:52:28
Current Time: Monday, 20-Jun-2016 01:23:56 CST
Restart Time: Monday, 20-Jun-2016 01:20:59 CST
Parent Server Generation: 0
Server uptime: 2 minutes 57 seconds
1 requests currently being processed, 7 idle workers
_W______........................................................ ................................................................ ................................................................ ................................................................
Scoreboard Key:
"_
" Waiting for Connection, "S
" Starting up, "R
" Reading Request,
"W
" Sending Reply, "K
" Keepalive (read), "D
" DNS Lookup,
"C
" Closing connection, "L
" Logging, "G
" Gracefully finishing,
"I
" Idle cleanup of worker, ".
" Open slot with no current process
查看日志文件,也已经自动生成
[root@localhost logs]# ls
access_log error_log www1_access www1_error www2_access www2_error
通过以上配置和测试,已经满足前三个要求
本文出自 “linux” 博客,请务必保留此出处http://wei2008.blog.51cto.com/11351016/1826543
标签:httpd基本应用
原文地址:http://wei2008.blog.51cto.com/11351016/1826543