mac配置apache
http://www.cnblogs.com/snandy/archive/2012/11/13/2765381.html
用自带的
sudo apachectl -v
sudo apachectl start
sudo apachectl stop
sudo apachectl restart
web默认目录在/Library/WebServer/Documents/
设置虚拟主机
- 在终端运行“
sudo vi /etc/apache2/httpd.conf”,打开Apche的配置文件 - 在httpd.conf中找到“
#Include /private/etc/apache2/extra/httpd-vhosts.conf”,去掉前面的“#”,保存并退出。 - 运行“
sudo apachectl restart”,重启Apache后就开启了虚拟主机配置功能。 - 运行“
sudo vi /etc/apache2/extra/httpd-vhosts.conf”,就打开了配置虚拟主机文件httpd-vhost.conf,配置虚拟主机了。需要注意的是该文件默认开启了两个作为例子的虚拟主机:123456789101112131415<VirtualHost*:80>ServerAdmin webmaster@dummy-host.example.comDocumentRoot "/usr/docs/dummy-host.example.com"ServerName dummy-host.example.comErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common</VirtualHost><VirtualHost*:80>ServerAdmin webmaster@dummy-host2.example.comDocumentRoot "/usr/docs/dummy-host2.example.com"ServerName dummy-host2.example.comErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common</VirtualHost>而实际上,这两个虚拟主机是不存在的,在没有配置任何其他虚拟主机时,可能会导致访问localhost时出现如下提示:
Forbidden You don't have permission to access /index.php on this server最简单的办法就是在它们每行前面加上#,注释掉就好了,这样既能参考又不导致其他问题。
- 增加如下配置
12345678910111213141516171819
<VirtualHost*:80>DocumentRoot "/Library/WebServer/Documents"ServerName localhostErrorLog "/private/var/log/apache2/localhost-error_log"CustomLog "/private/var/log/apache2/localhost-access_log" common</VirtualHost><VirtualHost*:80>DocumentRoot "/Users/snandy/work"ServerName mysitesErrorLog "/private/var/log/apache2/sites-error_log"CustomLog "/private/var/log/apache2/sites-access_log" common<Directory/>Options Indexes FollowSymLinks MultiViewsAllowOverride NoneOrder deny,allowAllow from all</Directory></VirtualHost>保存退出,并重启Apache。

浙公网安备 33010602011771号