服务器"/>
基于域名访问web服务器
创建基于域名的虚拟主机,能够使用www.xiaopang和www.dapang访问各自网站,存放路径分别为/www/xiaopang和/www/dapang
第一步:创建目录
[root@catyuan ~]# mkdir /www/{dapang,xiaopang} -p第二步:修改配置文件
<Directory "/www">AllowOverride None# Allow open access:Require all granted
</Directory><VirtualHost 192.168.198.10:80>DocumentRoot "/www/xiaopang"ServerName www.xiaopangErrorLog "/var/log/httpd/dummy-host.example-error_log"CustomLog "/var/log/httpd/dummy-host.example-access_log" common
</VirtualHost><VirtualHost 192.168.198.11:80>DocumentRoot "/www/dapang"ServerName www.dapangErrorLog "/var/log/httpd/dummy-host.example-error_log"CustomLog "/var/log/httpd/dummy-host.example-access_log" common
</VirtualHost>第三步:域名解析
linux下:/etc/hosts
windows下:c:\windows\system32\drvers\etc\hosts[root@catyuan ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.198.10 www.xiaopang
192.168.198.11 www.dapang ##加入这两行解析第四步:写入内容
[root@catyuan ~]# echo this is dapang > /www/dapang/index.html
[root@catyuan ~]# echo this is xiaopang > /www/xiaopang/index.html第五步:重启测试
更多推荐
基于域名访问web服务器
发布评论