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