拿配置MacOs PHP环境举例子
- 首先需要本机上有Web服务器,安装Apache。不过一般Linux发行版本自带apache,所以Mac上应该也有Apache,启动一下就好。参考
- 然后参考php官网上安装教程,这边是使用homebrew来下载安装,执行命令
brew install php
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php_module /usr/local/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:
/usr/local/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:
/usr/local/opt/php/sbin/php-fpm --nodaemonize
==> git
The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the `git-gui` formula.
zsh completions and functions have been installed to:
/usr/local/share/zsh/site-functions
Emacs Lisp files have been installed to:
/usr/local/share/emacs/site-lisp/git
- 根据上面执行结果配置httpd.conf文件并重启apache,注意httpd.conf是只读文件,可以更改文件权限或者使用管理员权限进行更改操作,参考
- MACOS下安装PHP运行环境