- 1.编辑apache配置文件
- vim /etc/httpd/conf/httpd.conf
- #在最后面添加如下内容
- Listen 81
- Listen 82
- <VirtualHost *:81>
- ServerAdmin http://192.168.1.39
- DocumentRoot /data/vhost1
- ErrorLog logs/vhost1_error_log
- CustomLog logs/vhost1_access_log common
- </VirtualHost>
- <VirtualHost *:82>
- ServerAdmin http://192.168.1.39
- DocumentRoot /data/vhost2
- ErrorLog logs/vhost1_error_log
- CustomLog logs/vhost1_access_log common
- </VirtualHost>
- 2.创建目录
- mkdir /data/vhost1
- mkdir /data/vhost2
- 3.添加测试文件
- vim /data/vhost1/index.html
- #添加如下内容:
- vhost1
- vim /dta/vhost2/index.html
- #添加如下内容:
- vhost2
- 4 重启apache 服务器
- /etc.init.d/httpd restart
- 5.测试
- 在浏览器里面分别输入 http://ip:81 和 http://ip:82
- 显示结果应该是: vhost1 和 vhost2