安装和配置 Apache 及 PHP
sudo apachectl stop
sudo rm -rf /etc/apache2
sudo rm -rf /usr/sbin/httpd
sudo rm -rf /Library/WebServer
brew install httpd
sudo brew services start httpd编辑 Apache 配置文件 /opt/homebrew/etc/httpd/httpd.conf
sudo brew services restart httpd打开浏览器并访问 http://localhost:8080//opt/homebrew/var/www
brew install php
LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so
在 httpd.conf 中,确保 Apache 配置支持 .php 文件的解析。确保以下部分没有被注释掉:<IfModule dir_module>DirectoryIndex index.php index.html</IfModule>在 httpd.conf 文件末尾添加:AddType application/x-httpd-php .php
sudo brew services restart httpd
nano /usr/local/var/www/index.php<?phpphpinfo();?>打开浏览器访问 http://localhost/index.php,查看 PHP 配置信息页面