mac 上配置apache虚拟主机


转自:https://jason.pureconcepts.net/2012/10/install-apache-php-mysql-mac-os-x/

编辑你的 apache 配置文件:

vim /etc/apache2/httpd.conf

去掉这一行的注释:

Include /peivate/etc/apache2/extra/httpd-vhosts.conf

这时,apache 将会加载 httpd-vhosts.conf 这个配置文件

编辑httpd-vhost.conf 配置文件:

vim /etc/apache2/extra/http-vhosts.conf

这里给一个例子:

<VirtualHost *:80>
        DocumentRoot "/Users/Jason/Documents/workspace/dev"
        ServerName jason.local
        ErrorLog "/private/var/log/apache2/jason.local-error_log"
        CustomLog "/private/var/log/apache2/jason.local-access_log" common

        <Directory "/Users/Jason/Documents/workspace/dev">
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>
上面的配置表明,我可以通过访问http://jason.local 访问到本地的/User/Json/Documemts/workspace/dev 下的文件,

重启apache:apachectl restart
最后一步,编辑hosts文件:
vim /etc/hosts
添加:127.0.0.1 json.local
运行以下命令清除DNS缓存:dscacheutil -flushcache
如果你想验证配置文件是否有错误,运行:apachectl configtest
 



免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM