关于 MAC 配置 Apache2 + PHP

相关路径

  1. 默认服务路径
/Library/WebServer/Documents
  1. 配置文件路径
/etc/apache2/httpd.conf
/etc/apache2/extra/httpd-vhosts.conf

httpd.conf 配置

  1. 开启 rewrite
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
  1. 开启 php
LoadModule php7_module libexec/apache2/libphp7.so
  1. 开启 vhosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

httpd-vhosts.conf 配置

<VirtualHost *:80>
 ServerName localhost
 DocumentRoot /Library/WebServer/Documents
 <Directory "/Library/WebServer/Documents">
 AllowOverride All
 Require all granted
 </Directory>
 ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
 CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
 ServerName namecho.io
 DocumentRoot /Users/namecho/Workspace/namecho/public
 <Directory "/Users/namecho/Workspace/namecho/public">
 AllowOverride All
 Require all granted
 </Directory>
 ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
 CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>

评论

暂无评论