Mac:Apache配置

来自WHY42
sudo apachectl start

修改/etc/apache2/httpd.conf

LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php7_module libexec/apache2/libphp7.so

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

修改httpd-vhosts.conf

<VirtualHost *:80>
    ServerAdmin dr@riguz.com
    DocumentRoot "/Users/hfli/Sites/riguz.com"
    ServerName local.riguz.com
    ServerAlias www.local.riguz.com
    ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
    CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
    <Directory "/Users/hfli/Sites/riguz.com">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>

然后在/Users/hfli/Sites/riguz.com中创建index.php

<?php
    phpinfo();
?>

最后需要修改local.riguz.com指向本机。然后重启Apache即可。