文章目录 安装PHP配置Apache后记 安装PHP brew install php@7.4echo 'export PATH="/opt/homebrew/opt/php@7
brew install php@7.4echo 'export PATH="/opt/homebrew/opt/php@7.4/bin:$PATH"' >> ~/.zshrcecho 'export PATH="/opt/homebrew/opt/php@7.4/sbin:$PATH"' >> ~/.zshrcexport LDFLAGS="-L/usr/local/opt/php@7.4/lib"export CPPFLAGS="-I/usr/local/opt/php@7.4/include"brew link --overwrite --force php@7.4
使用php -v
查看是否安装成功
mkdir /Users/xzs/www
/etc/apache2/Httpd.conf
,每个代码块代表着对应的修改部分#Listen xx.xx.xx.xx:80Listen 127.0.0.1:80
#添加下行内容LoadModule php7_module /opt/homebrew/Cellar/php@7.4/7.4.30/lib/httpd/modules/libphp7.so (根据具体安装位置修改)
#ServerName www.example.com:80ServerName localhost
#DocumentRoot "/Library/WEBServer/Documents"# DocumentRoot "/Users/xzs/www"<Directory "/Users/xzs/www">
# 添加下述内容<FilesMatch .php$>SetHandler application/x-httpd-php</FilesMatch>
# #DirectoryIndex index.html#<IfModule dir_module$>DirectoryIndex index.html index.php</IfModule>
<Directory /> #AllowOverride none # Require all denied Require all granted AllowOverride all</Directory>
#Include /private/etc/apache2/extra/httpd-vhosts.confInclude /private/etc/apache2/extra/httpd-vhosts.conf
详细步骤参考:https://scriptverse.academy/blog/codesign-certificate-Mac.html
LoadModule php7_module /opt/homebrew/Cellar/php@7.4/7.4.30/lib/httpd/modules/libphp7.so "codesign"
详细步骤参考:https://blog.csdn.net/simplty/article/details/43021375
.htaccess
文件# 进入到网站根目录的上级目录cd /Users/xzstouch .htaccess# 写入如下内容Order allow,denyAllow from allRequire all granted
# 确保网站根目录的上级目录具有可执行权限cd /Userschmod +x xzs
cd /Users/xzs/wwwecho "" > index.php
安装php扩展,以soap为例
到php官网下载对应版本的源码包
tar zxvf php-7.4.30.tar.gz./configure --enable-soap=shared --without-iconv --without-pear --disable-pharmakecp modules/soap.so /opt/homebrew/Cellar/php@7.4/7.4.30/pecl/2019090/
因为自带的Apache2配合PHP的环境经常出现一些莫名其妙的问题,比如修改php.ini
没有效果等等,目前采用通过Docker搭建Nginx+php的环境。
具体可参考:https://www.runoob.com/docker/docker-install-php.html
来源地址:https://blog.csdn.net/weixin_44700621/article/details/126323834
--结束END--
本文标题: M1芯片MAC配置Apache+PHP环境
本文链接: https://www.lsjlt.com/news/408215.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0