基于域名访问web服务器

编程入门 行业动态 更新时间:2024-10-10 01:23:09

基于域名访问web<a href=https://www.elefans.com/category/jswz/34/1771423.html style=服务器"/>

基于域名访问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服务器

本文发布于:2024-03-10 09:54:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1727649.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:服务器   域名   web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!