Apache for Mac

Mac 自带 Apache, PHP。只需要自己安装 MySQL。

1 配置 Apache

配置文件路径 /etc/apache2/httpd.conf。打开注释行 #Include /private/etc/apache2/extra/httpd-vhosts.conf

在虚拟主机配置文件(上面第二个)中使用如下配置:

<VirtualHost *:80>
  DocumentRoot "/Library/WebServer/Documents"
  ServerName localhost
  ErrorLog "/private/var/log/apache2/localhost-error_log"
  CustomLog "/private/var/log/apache2/localhost-access_log" common
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot "/Users/qiao/apache"//指定目录
  ServerName mysites.com//对应 host。需要在 hosts 中修改。
  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
      Require all granted // 一定要记得加
    </Directory>
</VirtualHost>

在 hosts 中添加域名指向 127.0.0.1。

如果开启了 surge 等软件。有可能刚开始虚拟域名会去 DNS 解析。可以先关掉,或者添加规则。

重启 Apache sudo apachectl restart

2 MySQL

官网下载 MySQL 和 Workbench。

/usr/local/mysql/bin/mysql 并没有被加入环境变量。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容