1.打开终端,输入命令:
sudo su
输入密码后切换到root权限
2.编辑httpd.conf文件,输入命令:
vim /etc/apache2/httpd.conf
3.将Include /private/etc/apache2/extra/httpd-vhosts.conf这行前的注释符号#去掉。
4.编辑httpd-vhosts.conf文件,输入命令:
vim /etc/apache/extra/httpd-vhosts.conf
5.在httpd-vhosts.conf 中添加以下内容:
<VirtualHost *:80>
ServerAdmin webmaster@xiaohua.com
DocumentRoot "/Users/yournameDev/xiaohua.com"
ServerName xiaohua.com
ErrorLog "/Users/yourname/Dev/xiaohua.com/error_log"
CustomLog "/Users/yourname/Dev/xiaohua.com/access_log" common
<Directory "/Users/yourname/Dev/xiaohua.com">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
6.重启Apache,输入命令:
apachectl restart
7.由于是在本地测试开发网站,还需要修改hosts文件,来将你的域名xiaohua. com对应本地的IP,输入命令:
vim /etc/hosts
8.添加如下内容后保存:
127.0.0.1 xiaohua.com