【笔记】MacOS上部署ApachePHP环境

前言

MacOS上部署ApachePHP环境

下载Apache依赖

1
brew install httpd

下载PHP依赖

1
brew install php

Apache配置文件中启用PHP插件

/opt/homebrew/etc/httpd/httpd.conf
1
2
3
4
5
LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>

Apache配置文件中添加默认首页

  • 添加index.php作为首页
/opt/homebrew/etc/httpd/httpd.conf
1
2
3
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>

启动Apache服务

1
brew services start httpd

完成