mac 配置lnmp环境
brew install php@8.2
已经安装php 8.2
命令: brew services start php@8.2
php.ini :
配置: /opt/homebrew/etc/php/8.2/
php-fpm : /opt/homebrew/etc/php/8.2/php-fpm.conf
命令路径:/opt/homebrew/opt/php@8.2/bin/phpize
— 激活本地php 环境—
echo 'export PATH="/opt/homebrew/opt/php@8.2/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/php@8.2/sbin:$PATH"' >> ~/.zshrc
已经安装 brew-php-switcher
brew install brew-php-switcher
brew-php-switcher 8.3
# 切换版本
brew install php@8.3 php@8.2 php@8.1 php@8.0
brew unlink php && brew link php@8.3
brew unlink php && brew link php@8.2
2安装redis-------
brew install redis
3 mysql 我是直接安装的安装件 —
https://dev.mysql.com/downloads/mysql/
根据自己的系统下载安装。
4.安装扩展 swoole—
brew install pcre2 (如果已经安装 不用安装)
下载: https://wiki.swoole.com/zh-cn/#/environment
cd swoole-src && \
phpize && \
./configure && make && make install
如果遇到错误:
In file included from /Users/username/Downloads/swoole-6.0.2/swoole-6.0.2/ext-src/php_swoole.cc:26: /opt/homebrew/Cellar/php@8.2/8.2.29/include/php/ext/pcre/php_pcre.h:23:10: fatal error: 'pcre2.h' file not found 23 | #include "pcre2.h" | ^~~~~~~~~ 1 error generated. make: *** [ext-src/php_swoole.lo] Error 1
export CPPFLAGS="-I/opt/homebrew/opt/pcre2/include"
export LDFLAGS="-L/opt/homebrew/opt/pcre2/lib"
phpize
./configure --with-php-config=$(which php-config)
make
sudo make install
swoole 6.不需要再加 --with-pcre-dir,Swoole 6 的 configure 脚本不会识别它
需要配置:
export CPPFLAGS="-I/opt/homebrew/opt/pcre2/include"
export LDFLAGS="-L/opt/homebrew/opt/pcre2/lib"
再make 和make install