主机ip: 192.168.7.51 Centos6.5
三个目录
/usr/ftp/test
/usr/ftp/dev
/usr/ftp/demo
实现效果
192.168.7.51:8052访问/usr/ftp/dev目录
192.168.7.51:8053访问/usr/ftp/test目录
192.168.7.51:8054访问/usr/ftp/demo目录
apache安装目录
/usr/local/apache
- 先放开三个端口
vi /usr/local/apache/conf/httpd.conf(apache的主配置文件)
Listen 80 在这行下面加
Listen 8052
Listen 8053
Listen 8054
2. 配置虚拟主机(在httpd.conf文件底部加就行)
<VirtualHost 192.168.7.51:8052>
DocumentRoot "/usr/ftp/dev/"
Options Indexes 显示目录索引
</VirtualHost><VirtualHost 192.168.7.51:8053>
DocumentRoot "/usr/ftp/test/"
Options Indexes
</VirtualHost><VirtualHost 192.168.7.51:8054>
DocumentRoot "/usr/ftp/demo/"
Options Indexes
</VirtualHost>
3. 重启apache
cd /usr/local/apache/bin
./apachectl stop
./apachectl start
4. 这样可以依次访问了
http://192.168.7.51:8052
http://192.168.7.51:8053
http://192.168.7.51:8054
5. 错误
You don‘t have permission to access / on this server
6. 解决办法
解决办法,找到这一段
<Directory />
AllowOverride none
Require all denied
</Directory>
把第二句注释掉
<Directory />
AllowOverride none
#Require all denied
</Directory>
7. 重启ok