apache 配置虚拟主机

1.编辑httpd.conf文件

   sudo vi /etc/apache2/httpd.conf   

找到Include /private/etc/apache2/extra/httpd-vhosts.conf  去掉此行前的#号。


2.编辑/etc/apache2/extra/httpd-vhosts.conf 文件

<VirtualHost *:80>
    DocumentRoot "/Users/<span style="color:#ff0000;">suibingyue</span>/site/php"
    ServerName ppp
    ErrorLog "/private/var/log/apache2/sites-error_log"
    CustomLog "/private/var/log/apache2/sites-access_log" common
    <Directory />
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>

3.保存后重启Apache

sudo apachectl restart

4.编辑hosts文件

127.0.0.1 localhost
127.0.0.1 suibingyue
127.0.0.1 ppp

5.测试

浏览器打开 http://php

你会发现

apache 配置虚拟主机_第1张图片

<Directory />
    AllowOverride none
    <span style="color: rgb(255, 0, 0); font-family: Menlo; line-height: 28px;">Require all denied 改为</span><span style="color:#ff0000;">granted</span>
</Directory>

重启测试,OK

It works!


你可能感兴趣的:(apache,mac,虚拟主机)