来源:http://www.infoshare.cc/
1、配置/etc/apache2/httpd.conf,打开httpd.conf,找到下面3行,将其前面注释#去除
LoadModule php5_module libexec/apache2/libphp5.so
Include /private/etc/apache2/other/*.conf
Include /private/etc/apache2/extra/httpd-vhosts.conf
2、创建个人站点
- 创建目录:/Users/macbook/Sites (macbook为你自己的用户名)
- 打开/etc/apache2/users/macbook.conf(如果没有自行创建),输入配置:
<Directory "/Users/macbook/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
3、创建虚拟主机
打开 /etc/apache2/extra/httpd-vhosts.conf
输入
<VirtualHost *:80>
DocumentRoot "/Users/macbook/Sites/"
ServerName www.macbook.com
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
4、修改host
打开/etc/hosts
输入
127.0.0.1 www.macbook.com
5、重启服务
apachectl restart
6、浏览器访问(XX为/Users/macbook/Sites目录下面次级目录,也可以将index.php目录放在Sites下面,直接访问http://www.macbook.com/index.php)
http://www.macbook.com/XX/index.php