博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
配置虚拟主机
阅读量:2387 次
发布时间:2019-05-10

本文共 2240 字,大约阅读时间需要 7 分钟。

实验步骤:
1、安装apache相关的rpm包(httpd、httpd-manual、httpd-devel)
2、修改apache的配置文件
具体步骤:
1、安装rpm包
[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
2、修改apache的配置文件
[root@localhost ~]#vim /etc/httpd/conf/httpd.conf
建议不要在原来的基础上修改,复制出一份再作修改;
#NameVirtualHost *:80
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>
<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 ---正确日志的存放目录
</VirtualHost>
3、重启apache服务
[root@localhost ~]#service httpd restart
4、创建网页文件
[root@localhost ~]#cd /var/www
[root@localhost www]#mkdir baidu
[root@localhost www]#mkdir google
[root@localhost www]#vim baidu/index.html
welcome to baidu!!!!!!
[root@localhost www]#vim google/index.html
welcome to google!!!!!!
5、测试
前提DNS要能提供域名解析
打开浏览器:
输入
输入
*********************************************************************
扩展:
apache实现身份验证
1、制作被保护的目录
[root@localhost ~]#cd /var/www/baidu
[root@localhost baidu]#mkdir ASUS
[root@localhost baidu]#vi ASUS/index.html ---ASUS/index.html是受保护的文件
2、建立密码文件
[root@localhost baidu]#cd ..
[root@localhost www]#htpasswd -c apache.passwd user1
New password:****
Re-type new password:****
Adding password for user user1
3、修改apache的配置文件,是加密文件生效
[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 -----允许所有通过身份验证的用户访问
</Directory>
4、重启apache服务
[root@localhost www]#service httpd restart
5、测试
在浏览器中输入: 能正常访问baidu
再在后面跟上“/ASUS”敲回车,提示输入用户名和密码
正确输入用户名和密码后,就能访问到里面的内容。

转载地址:http://dlsab.baihongyu.com/

你可能感兴趣的文章
New Tool: The PenTesters Framework (PTF) Released
查看>>
Detecting and Defending against PowerShell Shells
查看>>
NagVis实物监控工具
查看>>
nginx - low risk webdav destination bug
查看>>
Lessons Learned from Building and Running MHN, the World's Largest Crowdsourced Honeynet
查看>>
Logwatch Linux/Unix系统日志检测软件
查看>>
减少Linux下Squid服务器的TIME_WAIT套接字数量
查看>>
/etc/sudoers中的含义
查看>>
Five must-know open source SDN controllers
查看>>
Finding Bad Guys with 35 million Flows, 2 Analysts, 5 Minutes and 0 Dollars
查看>>
SANS FOR572 Logstash
查看>>
apt成熟度模型
查看>>
Digital Forensics Framework v0.4.3 available
查看>>
linux设置bond网卡绑定
查看>>
Is your .svn showing (like 3300 other sites)?
查看>>
PCI DSS Update Could Include Virtualization Security(转载自baoz)
查看>>
List of Windows Auto Start Locations
查看>>
OSSIM 2.1 - Multiple security vulnerabilities
查看>>
PHP文件上传源码分析(RFC1867)
查看>>
关于php5.*后的时区问题 date_default_timezone_set ();
查看>>