摘要
正在生成中……
在使用 brew install php@8.2
安装后,日志会贴心地给你一些信息,比如php.ini 、php-fpm
配置文件的位置和启动信息:
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.2/
To start php now and restart at login:
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
但是当我使用brew services start php
时,出现报错
Error: uninitialized constant Homebrew::Service::System
/opt/homebrew/Library/Homebrew/macos_version.rb:150:in `const_missing'
/opt/homebrew/Library/Taps/homebrew/homebrew-services/cmd/services.rb:61:in `services'
/opt/homebrew/Library/Homebrew/brew.rb:86:in `<main>'
不仅是brew services start
,所有跟brew services
相关的命令都会报错,比如 brew services list
。
稍加搜索可以在github上找到相关issue:
brew services Error: uninitialized constant Homebrew::Service::System · Issue #127329 · Homebrew/homebrew-core
原因是当前使用的 homebrew/services
镜像站或者仓库已经不维护了。可以使用命令查看当前使用的repo:
git -C $(brew --repo homebrew/services) remote get-url origin
我的是gitlab
的:
https://gitlab.com/mirrorx/homebrew-services.git
改成github
的就可以了
git -C "$(brew --repo homebrew/services)" remote set-url origin https://github.com/Homebrew/homebrew-services.git
最后再进行一次更新
brew update
大功告成,这下 brew services
就能正常使用了。