- 没有安装brew的童鞋,请先安装brew,不懂的可以百度
- 更新brew
brew update
- 安装php7.4
brew install [email protected] 安装成功会显示安装信息 安装位置 /usr/local/etc/php/7.4/ 重启命令 brew services restart [email protected] 后台运行 /usr/local/opt/[email protected]/sbin/php-fpm --nodaemonize 加入环境变量 echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc 使环境变量生效 source .zshrc
- 安装Nginx
brew install nginx 安装成功先显示路径等信息 默认文件目录 Docroot is: /usr/local/var/www 默认配置文件 浏览器打开 http://127.0.0.1:8080可以看到默认Nginx欢迎页 /usr/local/etc/nginx/nginx.conf 重启Nginx命令: brew services restart nginx 后台运行Nginx /usr/local/opt/nginx/bin/nginx -g daemon off; 多站点配置文件目录,新建站点配置文件放在此目录即可自动引用 /usr/local/etc/nginx/servers/ 下边就是一个完整的PHP站点配置文件内容 server { listen 8082; root /Users/lixu/code/phpmyadmin/; index index.php index.html index.htm; server_name www.test.loc; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }
- 安装MySQL
brew install [email protected] 安装位置 /usr/local/opt/[email protected]/ 安装成功后将MySQL加入环境变量 echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc 让环境变量立即生效 source ~/.zshrc 后台服务方式启动MySQL /usr/local/opt/[email protected]/bin/mysqld_safe --datadir=/usr/local/var/mysql 修改root密码 mysql_secure_installation
- 安装Redis
brew install redis Redis配置文件地址 /usr/local/etc/redis.conf Redis安装目录 /usr/local/opt/redis/bin/redis-server 后台运行Redis /usr/local/opt/redis/bin/redis-server /usr/local/etc/redis.conf
- 安装PHP的Redis扩展
下载 对应版本http://pecl.php.net/package/redis cd redis-5.1.1 执行phpize,phpize是PHP安装目录下面,默认在/usr/local/opt/[email protected]/bin/ /usr/local/opt/[email protected]/bin/phpize 编译安装 ./configure --with-php-config=/usr/local/opt/[email protected]/bin/php-config make && make install 编译成功后会输入目录地址 Installing shared extensions: /usr/local/Cellar/[email protected]/7.4.28_1/pecl/20190902/ 编辑php.ini 在末行增加以下代码 [redis] extension = /usr/local/Cellar/[email protected]/7.4.28_1/pecl/20190902/redis.so 重启PHP 即可 brew services restart [email protected]
- 安装PHPmyadmin
官网下载 PHPmyadmin,然后Nginx配置一下就好了
Mac安装nginx+php+mysql+redis
猜你喜欢
转载自blog.csdn.net/lixu1119545729/article/details/123425112
今日推荐
周排行