Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
66 lines (49 sloc) 1.34 KB
layout title tags keywords description category
post
mac apache 设置虚拟主机
javascript
mac apache
mac apache 设置虚拟主机
mac

$ sudo vim /etc/hosts.ac

修改hosts绑定。避免重启后恢复

$ sudo vim /et/hosts

同步修改 hosts。

$ sudo vi /etc/apache2/httpd.conf

<Directory />
    # Require all denied
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Order deny,allow
    Allow from all
</Directory>

#Include /private/etc/apache2/extra/httpd-vhosts.conf

LoadModule rewrite_module libexec/apache2/mod_rewrite.so #开启rewrite

#LoadModule php5_module libexec/apache2/libphp5.so 载入PHP

去掉# 保存

$ sudo vi /etc/apache2/extra/httpd-vhosts.conf

增加虚拟主机记录 示例:

<VirtualHost *:80>
    ServerAdmin noyobo@gmail.com
    DocumentRoot "/Users/noyobo/home"
    ServerName home.xiami.com
    ErrorLog "/private/var/log/apache2/home.xiami.com-error_log"
    CustomLog "/private/var/log/apache2/home.xiami.com-access_log" common
    <Directory "/Users/noyobo/home" >
        Options FollowSymLinks Indexes MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
        Require all granted  # 如果遇到 403 尝试开启
    </Directory>
</VirtualHost>
$ sudo apachectl stop
$ sudo apachectl start