本文共 2240 字,大约阅读时间需要 7 分钟。
1、安装apache相关的rpm包(httpd、httpd-manual、httpd-devel) [root@localhost ~]#mount /dev/cdrom /media/mnt ------挂在光盘 [root@localhost ~]#cd /media/mnt/Server [root@localhost Server]#rpm -ivh httpd-2.2.3-11.el5_1.3.i386.rpm [root@localhost Server]#rpm -ivh httpd-manual-2.2.3-11.el5_1.3.i386.rpm [root@localhost Server]#rpm -ivh httpd-devel-2.2.3-11.el5_1.3.i386.rpm [root@localhost ~]#vim /etc/httpd/conf/httpd.conf NameVirtualHost 192.168.1.217 -----添加(开启基于名字的虚拟主机) <VirtualHost 192.168.1.217> ServerAdmin webmaster@baidu.com ----管理员的邮箱地址 DocumentRoot /var/www/baidu -----保存网页的目录 ServerName www.baidu.com -----访问网站的域名 ErrorLog logs/baidu.com-error_log -----错误日志的存放目录 CustomLog logs/baidu.com-access_log common ---正确日志的存放目录 <VirtualHost 192.168.1.217> ServerAdmin webmaster@google.com ----管理员的邮箱地址 DocumentRoot /var/www/google -----保存网页的目录 ServerName www.google.com -----访问网站的域名 ErrorLog logs/google.com-error_log -----错误日志的存放目录 CustomLog logs/google.com-access_log common ---正确日志的存放目录 [root@localhost ~]#service httpd restart [root@localhost ~]#cd /var/www [root@localhost www]#mkdir baidu [root@localhost www]#mkdir google [root@localhost www]#vim baidu/index.html [root@localhost www]#vim google/index.html ********************************************************************* [root@localhost ~]#cd /var/www/baidu [root@localhost baidu]#mkdir ASUS [root@localhost baidu]#vi ASUS/index.html ---ASUS/index.html是受保护的文件 [root@localhost baidu]#cd .. [root@localhost www]#htpasswd -c apache.passwd user1 Re-type new password:**** Adding password for user user1 [root@localhost www]#vim /etc/httpd/conf/httpd.conf <Directory "/var/www/baidu/ASUS"> AuthName "ASUS Directory" AuthType Basic -----采用的加密算法 AuthUserFile /var/www/apache.passwd -----密码文件的存放目录 require valid-user -----允许所有通过身份验证的用户访问 [root@localhost www]#service httpd restart 再在后面跟上“/ASUS”敲回车,提示输入用户名和密码 转载地址:http://dlsab.baihongyu.com/