一、 添加虚拟域名
sh-3.2# vim /etc/hosts
127.0.0.1 www.cpath.com
二、 配置apache 配置文件
vim /etc/apache2/httpd.conf
# 把注释打开
Include /private/etc/apache2/extra/httpd-vhosts.conf
/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerName www.cpath.com
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">
Options FollowSymLinks IncludesNOEXEC Indexes
DirectoryIndex index.html index.htm index.php
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
# 重启apache
sh-3.2# sudo apachectl restart
三、浏览器输入
www.cpath.com
本文介绍如何在Apache服务器中配置虚拟主机。主要步骤包括:编辑hosts文件添加虚拟域名映射、修改Apache配置文件启用虚拟主机模块并配置具体设置,最后通过浏览器验证配置是否成功。
1136

被折叠的 条评论
为什么被折叠?



