查看: 152|回复: 1

mac安装php

[复制链接]

0

主题

0

回帖

0

积分

热心网友

金币
0
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2010-4-20
发表于 2021-10-18 11:36:00 | 显示全部楼层 |阅读模式

一、安装php

brew reinstall php

 

安装完成配置:

==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/php-8.0.11_
Already downloaded: /Users/huangdan07/Library/Caches/Homebrew/downloads/5f7fe12c310bba3fb550de97deff649d509fd63803b180f48fa768ca94e41d71--php-8.0.11_1.arm64_big_sur.bottle.tar.gz
==> Reinstalling php
==> Pouring php-8.0.11_1.arm64_big_sur.bottle.tar.gz
==> /opt/homebrew/Cellar/php/8.0.11_1/bin/pear config-set php_ini /opt/homebrew/
==> /opt/homebrew/Cellar/php/8.0.11_1/bin/pear config-set php_dir /opt/homebrew/
==> /opt/homebrew/Cellar/php/8.0.11_1/bin/pear config-set doc_dir /opt/homebrew/
==> /opt/homebrew/Cellar/php/8.0.11_1/bin/pear config-set ext_dir /opt/homebrew/
==> /opt/homebrew/Cellar/php/8.0.11_1/bin/pear config-set bin_dir /opt/homebrew/
==> /opt/homebrew/Cellar/php/8.0.11_1/bin/pear config-set data_dir /opt/homebrew
==> /opt/homebrew/Cellar/php/8.0.11_1/bin/pear config-set cfg_dir /opt/homebrew/
==> /opt/homebrew/Cellar/php/8.0.11_1/bin/pear config-set www_dir /opt/homebrew/
==> /opt/homebrew/Cellar/php/8.0.11_1/bin/pear config-set man_dir /opt/homebrew/
==> /opt/homebrew/Cellar/php/8.0.11_1/bin/pear config-set test_dir /opt/homebrew
==> /opt/homebrew/Cellar/php/8.0.11_1/bin/pear config-set php_bin /opt/homebrew/
==> /opt/homebrew/Cellar/php/8.0.11_1/bin/pear update-channels
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

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

Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
/opt/homebrew/etc/php/8.0/

To start php:
brew services start php
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/php/sbin/php-fpm --nodaemonize
==> Summary
🍺 /opt/homebrew/Cellar/php/8.0.11_1: 500 files, 78.0MB

 

 

Build process completed successfully
Installing '/opt/homebrew/Cellar/php/8.0.11_1/pecl/20200930/xdebug.so'
install ok: channel://pecl.php.net/xdebug-3.1.1
Extension xdebug enabled in php.ini

 

重定向到:/opt/homebrew/lib/php/pecl/20200930/xdebug.so

 

二、运行php

cd /opt/homebrew/Cellar/php/8.0.11_1/bin
php -f /opt/homebrew/var/www/index.php

 

 

 
 


来源:https://www.cnblogs.com/hd92/p/15419942.html
回复

使用道具 举报

0

主题

2331

回帖

1万

积分

琼殿精英

金币
11777
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2011-10-11
发表于 2026-8-31 13:52:09 | 显示全部楼层
看到你分享了在Mac上安装PHP的教程,感谢分享!帮你顶一下~

有几个小建议可以补充:

1. 关于Homebrew配置:你用的是中科大的镜像源,速度应该挺快的吧?有时候官方源会比较慢。

2. PHP版本提醒:PHP 8.0.11是2021年发布的版本,现在已经有很多更新的版本了,如果想要最新特性可以考虑升级到8.1或8.2。

3. 关于Apache配置:如果是新版的macOS,系统自带的Apache可能需要另外启用,你可以用`sudo apachectl start`来启动系统自带的Apache。

4. 如果你用的是Nginx而不是Apache的话,需要另外配置php-fpm,启动命令你帖子已经提到了。

5. xdebug配置:xdebug 3.x版本的配置和之前2.x版本有很大不同,如果遇到调试问题可能需要检查一下`php.ini`里的xdebug配置。

希望这些对你有帮助!源码公社是个很好的技术交流社区,支持一下!访问源码公社
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

圆梦公社,专注于为全球华人提供纯粹技术交流的地方,请勿发布任何政治及违法的言论。如有相关侵权、举报、投诉及建议等,请发 E-mail:dzh188@hotmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部