在Linux虚拟机下配置apache构建web服务器
- 格式:doc
- 大小:32.50 KB
- 文档页数:2
在Linux虚拟机下配置apache构建web服务器
2009年07月02日星期四 00:33
实现目的:
在Fedora10.0下架设Apache服务器,为Windows提供web访问服务。
实现不同用户(test1,test2,mm1,mm2)的不同访问权限。
并且实现基于IP(192.168.1.6与192.168.1.119)和端口(192.168.1.6:80与192.168.1.6:8090)的虚拟主机功能。
实现步骤:
安装好Fedora7.0后,系统已经安装好了Apache服务。
路径为 /etc/httpd
其中/etc/httpd/conf/httpd.conf为Apache服务的主配置文件,下面进行配置。
ServerRoot "/etc/httpd" //指定Apache服务的启动路径
Listen 192.168.1.6:80 //启动侦听端口
Listen 192.168.1.6:8090 //启动基于端口8090的虚拟主机的侦听
Listen 192.168.1.119:80 //启动基于端口80的虚拟主机的侦听
User apache
Group apache //指明启动Apache服务的用户和组
ServerAdmin ccx193@ //指明访问失败时的联系邮箱
ServerName :80 //指定服务器域名
DocumentRoot "/opt/ouc-server"
<Directory "/opt/ouc-server"> //指明web服务的目录DirectoryIndex index.php index.htm index.html index.html.var
//上面这一行指明当Apache服务接受访问时,搜索主页的顺序,由前至后
//下面实现基于IP的虚拟主机功能:
<VirtualHost 192.168.1.6:8090>
ServerAdmin root@localhost
DocumentRoot /var/www/html //定义该虚拟主机的目录
ServerName localhost
</VirtualHost>
<VirtualHost 192.168.1.119>
ServerAdmin root@localhost
DocumentRoot /var/www/html
ServerName localhost
</VirtualHost>
//用图形界面来添加一个ip记录
下面实现用户管理功能:
<Directory "/opt/ouc-server">
Authname "ccx's Apache server" //登录时显示在对话框上的提示信息
AuthType Basic //用户验证类型
AuthUserFile /etc/httpd/passwd //用户密码存放文件,需自己创建
AuthGroupFile /etc/httpd/groupfile // 组用户存放文件,需自己创建
Require group ouc //允许访问的组,我这里建立了组ouc
</Directory>
建立passwd文件:
# htpasswd /etc/httpd/passwd test1
# htpasswd /etc/httpd/passwd test2
#htpasswd /etc/httpd/passwd mm1
#htpasswd /etc/httpd/passwd mm2
建立groupfile文件:
# cat /etc/httpd/groupfile
ouc: test1 test2 mm1 mm2
重新启动Apache服务器:
# service httpd restart
下面我们就可以在Windows下访问建立好的网站.。