Mac下 brew 方式的LNMP环境搭建

1 安装前准备

1.1 添加Homebrew官方软件源

brew tap homebrew/versions
brew tap homebrew/php

1.2 更新brew

brew update	

2 安装mysql

2.1 安装MySQL

brew install mysql

成功安装结果

==> Caveats
==> protobuf Emacs Lisp files have been installed to: /usr/local/share/emacs/site-lisp/protobuf
==> mysql We’ve installed your MySQL database without a root password. To secure it run:
mysql_secure_installation

MySQL is configured to only allow connections from localhost by
default

To connect run:
mysql -uroot

To have launchd start mysql now and restart at login: brew services
start mysql Or, if you don’t want/need a background service you can
just run: mysql.server start

2.2 设置开机启动

brew方式设置开机启动

brew services start mysql

手动设置开机启动

cp /usr/local/Cellar/mysql/5.7.12/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

brew设置开机启动MySQL完成后的提示信息

If you need to have this software first in your PATH run: echo ‘export
PATH="/usr/local/opt/sphinx-doc/bin:$PATH"’ >> ~/.zshrc

/usr/local/Cellar/mysql/5.7.20/bin/mysqld --initialize-insecure
–user=king --basedir=/usr/local/Cellar/mysql/5.7.20 --datadir=/usr/local/var/mysql --tmpdir=/tmp

We’ve installed your MySQL database without a root password. To secure
it run: mysql_secure_installation

MySQL is configured to only allow connections from localhost by
default

A “/etc/my.cnf” from another install may interfere with a
Homebrew-built server starting up correctly.

To have launchd start mysql now and restart at login: brew services
start mysql

Or, if you don’t want/need a background service you can just run:
mysql.server start

2.3 MySQL常用命令

关闭并取消MySQL的开机启动服务

brew services stop mysql

登录&退出MySQL

mysql -uroot -p		
quit

启动/停止/重启

sudo mysql.server start/stop/restart

2.4 MySQL安全配置

注意:

需先运行mysql 。 否则会报错:Error: Can’t connect to local MySQL server
through socket ‘/tmp/mysql.sock’ (2)
提示说找不到mysql.sock,原因是mysql进程还没启动。

修改密码安全策略,并设置密码为123456

登录 MySQL

mysql -uroot 

设置密码强度检查等级, 0:只检查长度

set global validate_password_policy=0;

设置密码最小长度 LOW

set global validate_password_length=4;

查看密码策略

SHOW VARIABLES LIKE 'validate_password%';

设置密码:123456

mysql_secure_installation

2.5 配置文件介绍

查找mysql服务配置文件的位置

which mysqld
/usr/local/bin/mysqld
/usr/local/bin/mysqld --verbose --help | grep -A 1 'Default options'

Mac笔记本执行成功结果如图:
在这里插入图片描述

3 安装PHP

3.1 brew 安装php56

#查看php5.6安装选项
brew options php56   	  

#搜索PHP56安装包
brew search php56 	
  
 #安装php56
brew install homebrew/php/php56    

注意: php56中默认已安装 php-fpm, nginx, mysql扩展

成功安装结果
这里写图片描述
这里写图片描述

php56启动以及安装包垃圾清理
补充说明:

配置文件位置: /usr/local/etc/php/5.6/php-fpm.conf

# 杀死进程
sudo pkill php-fpm

# 重启进程
sudo /usr/local/opt/php56/sbin/php-fpm --fpm-config 

# 卸载
brew uninstall php56 

# 清除缓存以及老旧版本文件
brew cleanup -s

3.2 设置开机启动

brew方式设置开机启动

# To have launchd start homebrew/php/php56 now and restart at login:
brew services start homebrew/php/php56

手动方式设置开机启动

cp /usr/local/opt/php56/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist

3.3 替换Mac自带的PHP和php-fpm

补充说明:
  添加系统环境变量PATH来替代Mac自带PHP版本,即优先运行brew安装的PHP版本。

实现方式:
  添加环境变量
注意我们
本人笔记本用的zsh,由于Mac自带了php和php-fpm,因此需要

具体实现步骤:

#查看当前用的shell  并修改对应的配置文件
echo $SHELL    
/usr/local/bin/zsh   # 本人笔记本用的zsh 

#修改zash配置文件~/.zshrc
#for php
echo 'export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"' >> ~/.zshrc  
#for php-fpm
echo 'export PATH="$(brew --prefix homebrew/php/php56)/sbin:$PATH"' >> ~/.zshrc  
#for other brew install soft
echo 'export PATH="/usr/local/bin:/usr/local/sbin:$PATH"' >> ~/.zshrc 

#更新并使配置生效
source ~/.zshrc 

#在~/.zshrc 添加效果如下:
export PATH=/usr/local/opt/php56/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

补充说明:

通过shell配置文件设置一些环境变量,例:
~/.bashrc:
  该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该文件被读取.
~/.zshrc:
  该文件包含专用于你的zsh shell的bash信息,当登录时以及每次打开新的shell时,该文件被读取.

3.4 安装PHP扩展

补充说明:
  brew会自动安装默认的PHP扩展依赖包;
  brew方式下直接安装php扩展,而不用每次重新编译php,安装步骤如下:

3.4.1 bottle方式安装

补充说明:

默认情况下会采用 bottle 方式安装,bottle 方式就是安装已编译好的二进制包。

# 查找扩展
brew search php56  

# 安装扩展命令
brew install      homebrew/php/php56-crypto           homebrew/php/php56-igbinary    homebrew/php/php56-memcache  homebrew/php/php56-memcached    homebrew/php/php56-mongo    homebrew/php/php56-mongodb homebrew/php/php56-pthreads  homebrew/php/php56-redis         homebrew/php/php56-yaf  homebrew/php/php56-mcrypt  homebrew/php/php56-swoole  homebrew/php/php56-xdebug  homebrew/php/php56-opcache 

成功安装结果
这里写图片描述

3.4.1 源码方式安装

brew reinstall homebrew/php/php56-crypto --build-from-source
brew install homebrew/php/php56-xdebug --build-from-source

3.5 PHP常用命令

php –v 即可查看当前php的版本
php -m 会显示当前php加载的有效模块
php -i 输出无html格式的phpinfo
php -i |grep mongo 查看你的扩展是否安装成功
php -ini 输出当前php加载ini配置文件的数量,路径信息。
php –a 命令打开交互模式,输入一行代码,php会实时输出结果。
php -l hello.php 命令行下检测php文件的语法错误
php -s hello.php 将php代码高亮原样输出
php -rf function 打印出该函数的语法简介
php -re function 查看扩展
php-fpm -v 查看php-fpm版本
php --ini 查看所有配置文件位置

3.6 php7.0 安装

补充说明:

选择安装PHP70,是因为PHP71暂时没有memcache 扩展;

# 查看php70安装选项
brew options php70

# 安装命令
brew install php70

这里写图片描述
这里写图片描述
补充说明:

PHP70和PHP56安装差不多,但有一个地方主要注意:

  • please ‘brew unlink php56’ before continuing => 提示在安装PHP70之前需要去除之前php56的链接,这样才可以安装PHP70
#PHP7.0 扩展安装
brew install       homebrew/php/php70-igbinary    homebrew/php/php70-memcache  homebrew/php/php70-memcached    homebrew/php/php70-mongodb       homebrew/php/php70-pthreads  homebrew/php/php70-redis         homebrew/php/php70-yaf  homebrew/php/php70-mcrypt  homebrew/php/php70-swoole  homebrew/php/php70-xdebug  homebrew/php/php70-opcache  homebrew/php/php70-lua  homebrew/php/php70-gmagick 

3.7 PHP多版本控制

3.7.1 方式一:php-version实现版本控制

# 安装php-version
brew install php-version

列表内容
PHP版本切换实例
这里写图片描述

3.7.2 方式二: brew link|unlink

  通过brew安装的php可以通过brew link和brew unlink来切换不同版本。

3.7.3 方式三:配置环境变量

补充说明:

只生效一次

# 操作命令
 source $(brew --prefix php-version)/php-version.sh && php-version 5
要想长期生效需要 把这代码放到~/.bashrc 或者 ~/.zshrc 
# 查看当前PHP版本
php-version		

这里写图片描述

3.7.4 其它方式

http://www.piaoyi.org/php/Mac-brew-php.html
注意:安装多个PHP版本的时候, 要注意更改配置目录,其实本质上还是启动程序优先级问题.比如设置php56 在php70之前, 则用到的就是php56

5 Nginx 安装

安装nginx

# 搜索
brew search nginx

# 安装
brew install nginx

成功安装结果

Updating Homebrew…
==> Downloading https://homebrew.bintray.com/bottles/nginx-1.19.1.catalina.bottle.tar.gz
-=O=- # # # # curl: (35) LibreSSL SSL_connect: SSL_ERROR_ZERO_RETURN in connection to d29vzk4ow07wi7.cloudfront.net:443 Error: Failed to
download resource “nginx” Download failed:
https://homebrew.bintray.com/bottles/nginx-1.19.1.catalina.bottle.tar.gz
Warning: Bottle installation failed: building from source.
==> Downloading https://nginx.org/download/nginx-1.19.1.tar.gz
######################################################################## 100.0%
==> tar -cJf /usr/local/Cellar/nginx/1.19.1/share/nginx/src/src.tar.xz --options compress
==> ./configure --prefix=/usr/local/Cellar/nginx/1.19.1 --sbin-path=/usr/local/Cellar/ngi
==> make install
==> Caveats Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to
8080 so that nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/.

To have launchd start nginx now and restart at login: brew services
start nginx Or, if you don’t want/need a background service you can
just run: nginx
==> Summary 🍺 /usr/local/Cellar/nginx/1.19.1: 10 files, 2MB, built in 32 seconds

补充说明:

配置文件位置: /usr/local/etc/nginx/nginx.conf

nginx常用命令

# 启动
nginx	

# 重载/~/停止/~
nginx -s reload|reopen|stop|quit   	

# 校验配置文件是否正确
nginx -t 	
						
#查看安装Nginx时的编译选项(pid位置, Log日志 配置文件 安装目录 安装模块等)
nginx -V  						

设置开机启动

cp /usr/local/Cellar/nginx/1.10.0/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

设置nginx监听80端口
补充说明:

  nginx安装后默认监听8080端口,可以访 http://localhost:8080查看状态。

设置root权限,监听80端口

sudo chown root:wheel /usr/local/Cellar/nginx/1.6.2/bin/nginx
sudo chmod u+s  /usr/local/Cellar/nginx/1.6.2/bin/nginx

6 brew 方式 安装 Redis

安装

brew install redis

成功安装结果

To have launchd start redis now and restart at login: brew services
start redis #同时会把服务加入开机启动项 Or, if you don’t want/need a background
service you can just run: redis-server /usr/local/etc/redis.conf

手动方式设置开机启动
cp /usr/local/Cellar/redis/4.0.2/homebrew.mxcl.redis.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
手动方式设置停止开机启动 launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

redis常用命令

# 指定配置文件启动redis server
 redis-server /usr/local/etc/redis.conf

#进入命令行模式
redis-cli

# 停止redis server服务
redis-cli shutdown

# 测试redis server是否启动
redis-cli ping

#设置开机启动
brew services start/stop/restart redis

补充说明:

redis 配置文件的位置:/usr/local/etc/redis.conf

配置后台进程启动

vim /usr/local/etc/redis.conf

修改 daemonize no 为 daemonize yes  默认启动就后台运行

redis 设置密码

vim /usr/local/etc/redis.conf
# 修改密码
requirepass foobared	=>	requirepass pwdcode

重启redis

# 先登录redis,关闭服务
shutdown

# 启动服务
/usr/local/opt/redis/bin/redis-server /usr/local/etc/redis.conf     

登录redis

# 登录redis,发现可以登上,但是执行具体命令是提示操作不允许
redis-cli -h 127.0.0.1 -p 6379

# 尝试用密码登录并执行具体的命令看到可以成功执行
redis-cli -h 127.0.0.1 -p 6379 -a pwdcode 

7 brew 方式 安装 Memcache

#安装命令
brew install memcached

成功安装结果

#To have launchd start memcached now and restart at login: brew services start memcached
#Or, if you don’t want/need a background service you can just run: /usr/local/opt/memcached/bin/memcached

手动设置开机启动

cp  /usr/local/Cellar/memcached/1.5.2/homebrew.mxcl.memcached.plist ~/Library/LaunchAgents
launchctl load/unload ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist

连接memcache

telnet 127.0.0.1 11211

8 brew 方式 安装MongoDB

#安装命令
brew install mongodb

#常用命令
brew services start/stop/restart mongodb

#指定配置文件启动mongodb服务
sudo mongod
sudo mongod -f /usr/local/etc/mongod.conf

#启动客户端
mongo

#设置开机自启动
brew services stop/restart mongodb

brew 安装其他项目支持

brew install composer node

常见问题

问题一:启动mongodb报错

2020-07-12T19:09:45.434+0800 I STORAGE [initandlisten] exception in
initAndListen: NonExistentPath: Data directory /data/db not found.,
terminating

解决办法:
指定配置文件启动;

启动命令:
sudo mongod -f /usr/local/etc/mongod.conf

UPDATE

brew PHP7.4.8 安装过程

(base) ➜ ~ brew install php Updating Homebrew…
==> Auto-updated Homebrew! Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae ckan exploitdb
==> Updated Casks airy panoply sidequest baidunetdisk pocket-casts toggl
beersmith pokemon-reborn uu-booster
drawio private-internet-access webcatalog
fontlab pyfa wormhole
geotag-photos-pro razorsql itubedownloader
screaming-frog-seo-spider

==> Downloading https://homebrew.bintray.com/bottles/apr-1.7.0.catalina.bottle.t
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/277c42fcf2f5ca298a142
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/apr-util-1.6.1_3.catalina.b
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/425955a21c3fec8e78f36
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/argon2-20190702_1.catalina.
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/f8e550c8597728bb9edc5
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/aspell-0.60.8.catalina.bott
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/f34a5b53fa80f6f0ea3ce
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.catalina.bott
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/ca510b350e941fb939552
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/brotli-1.0.7.catalina.bottl
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/81be7d1d110787a534cd5
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/c-ares-1.16.1.catalina.bott
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/libidn-1.35.catalina.bottle
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/a720f31e3d82a3e537ae2
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/libmetalink-0.1.3.catalina.
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/jansson-2.13.1.catalina.bot
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/jemalloc-5.2.1_1.catalina.b
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/b1b211e5bead798c236d4
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/libev-4.33.catalina.bottle.
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/libevent-2.1.12.catalina.bo
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/b5f5e7607d76b9b41ecac
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/nghttp2-1.41.0.catalina.bot
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/d81b96cf82189cd4049ff
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/openldap-2.4.50.catalina.bo
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/c0f1fe7a472cba83a584b
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/rtmpdump-2.4%2B20151223_1.c
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/curl-openssl-7.71.1.catalin
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/3eb7b47868af07e3b766a
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/libtool-2.4.6_2.catalina.bo
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/af317b35d0a394b7ef55f
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/unixodbc-2.3.7.catalina.bot
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/03ba378d971af98d07652
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/freetds-1.2.3.catalina.bott
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/6aa188d6d4c85197a3bba
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/freetype-2.10.2.catalina.bo
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/16500bbd77b8bbeb9a4ad
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.32.3.catalina.bott
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/98f798c4a62c9db46cc6a
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/python%403.8-3.8.3_2.catali
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/307604a075d3df682ba45
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/glib-2.64.4.catalina.bottle
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/4ddc126dde12d96499950
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/gmp-6.2.0.catalina.bottle.t
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/2e6acd6e62d1b8ef08000
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/libpq-12.3.catalina.bottle.
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/2278f4c6e51a0be17b8fe
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/libsodium-1.0.18_1.catalina
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/db372521cd0b1861a5b57
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/libzip-1.7.2.catalina.bottl
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/oniguruma-6.9.5-rev1.catali
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/15241cccbb727a11200b6
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/tidy-html5-5.6.0.catalina.b
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/fb2134180fbdb92cc10f3
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/php-7.4.8.catalina.bottle.t
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/da81ec7dbe2ab2d9cbfcb
######################################################################## 100.0%
==> Installing dependencies for php: apr, apr-util, argon2, aspell, autoconf, brotli, c-ares, libidn, libmetalink, jansson, jemalloc,
libev, libevent, nghttp2, openldap, rtmpdump, curl-openssl, libtool,
unixodbc, freetds, freetype, sqlite, python@3.8, glib, gmp, libpq,
libsodium, libzip, oniguruma and tidy-html5
==> Installing php dependency: apr
==> Pouring apr-1.7.0.catalina.bottle.tar.gz
==> Caveats apr is keg-only, which means it was not symlinked into /usr/local, because Apple’s CLT provides apr.

If you need to have apr first in your PATH run: echo ‘export
PATH="/usr/local/opt/apr/bin:$PATH"’ >> ~/.zshrc

==> Summary 🍺 /usr/local/Cellar/apr/1.7.0: 59 files, 1.4MB
==> Installing php dependency: apr-util
==> Pouring apr-util-1.6.1_3.catalina.bottle.tar.gz
==> Caveats apr-util is keg-only, which means it was not symlinked into /usr/local, because Apple’s CLT provides apr (but not apr-util).

If you need to have apr-util first in your PATH run: echo ‘export
PATH="/usr/local/opt/apr-util/bin:$PATH"’ >> ~/.zshrc

==> Summary 🍺 /usr/local/Cellar/apr-util/1.6.1_3: 54 files, 785.7KB
==> Installing php dependency: argon2
==> Pouring argon2-20190702_1.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/argon2/20190702_1: 12 files, 599.2KB
==> Installing php dependency: aspell
==> Pouring aspell-0.60.8.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/aspell/0.60.8: 767 files, 322.4MB
==> Installing php dependency: autoconf
==> Pouring autoconf-2.69.catalina.bottle.4.tar.gz 🍺 /usr/local/Cellar/autoconf/2.69: 67 files, 3.0MB
==> Installing php dependency: brotli
==> Pouring brotli-1.0.7.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/brotli/1.0.7: 25 files, 2.2MB
==> Installing php dependency: c-ares
==> Pouring c-ares-1.16.1.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/c-ares/1.16.1: 74 files, 525.7KB
==> Installing php dependency: libidn
==> Pouring libidn-1.35.catalina.bottle.tar.gz
==> Caveats Emacs Lisp files have been installed to: /usr/local/share/emacs/site-lisp/libidn
==> Summary 🍺 /usr/local/Cellar/libidn/1.35: 72 files, 1.4MB
==> Installing php dependency: libmetalink
==> Pouring libmetalink-0.1.3.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/libmetalink/0.1.3: 31 files, 182.9KB
==> Installing php dependency: jansson
==> Pouring jansson-2.13.1.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/jansson/2.13.1: 11 files, 169.0KB
==> Installing php dependency: jemalloc
==> Pouring jemalloc-5.2.1_1.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/jemalloc/5.2.1_1: 16 files, 2MB
==> Installing php dependency: libev
==> Pouring libev-4.33.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/libev/4.33: 12 files, 454.7KB
==> Installing php dependency: libevent
==> Pouring libevent-2.1.12.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/libevent/2.1.12: 57 files, 1.9MB
==> Installing php dependency: nghttp2
==> Pouring nghttp2-1.41.0.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/nghttp2/1.41.0: 26 files, 2.7MB
==> Installing php dependency: openldap
==> Pouring openldap-2.4.50.catalina.bottle.tar.gz
==> Caveats openldap is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and
installing another version in parallel can cause all kinds of trouble.

If you need to have openldap first in your PATH run: echo ‘export
PATH="/usr/local/opt/openldap/bin: P A T H " ′ > >   / . z s h r c e c h o ′ e x p o r t P A T H = " / u s r / l o c a l / o p t / o p e n l d a p / s b i n : PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/openldap/sbin: PATH">> /.zshrcechoexportPATH="/usr/local/opt/openldap/sbin:PATH"’ >> ~/.zshrc

For compilers to find openldap you may need to set: export
LDFLAGS="-L/usr/local/opt/openldap/lib" export
CPPFLAGS="-I/usr/local/opt/openldap/include"

==> Summary 🍺 /usr/local/Cellar/openldap/2.4.50: 328 files, 6.8MB
==> Installing php dependency: rtmpdump
==> Pouring rtmpdump-2.4+20151223_1.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/rtmpdump/2.4+20151223_1: 20 files, 443.4KB
==> Installing php dependency: curl-openssl
==> Pouring curl-openssl-7.71.1.catalina.bottle.tar.gz
==> Caveats curl-openssl is keg-only, which means it was not symlinked into /usr/local, because macOS provides curl.

If you need to have curl-openssl first in your PATH run: echo
‘export PATH="/usr/local/opt/curl-openssl/bin:$PATH"’ >> ~/.zshrc

For compilers to find curl-openssl you may need to set: export
LDFLAGS="-L/usr/local/opt/curl-openssl/lib" export
CPPFLAGS="-I/usr/local/opt/curl-openssl/include"

==> Summary 🍺 /usr/local/Cellar/curl-openssl/7.71.1: 464 files, 3.5MB
==> Installing php dependency: libtool
==> Pouring libtool-2.4.6_2.catalina.bottle.tar.gz
==> Caveats In order to prevent conflicts with Apple’s own libtool we have prepended a “g” so, you have instead: glibtool and glibtoolize.
==> Summary 🍺 /usr/local/Cellar/libtool/2.4.6_2: 71 files, 3.7MB
==> Installing php dependency: unixodbc
==> Pouring unixodbc-2.3.7.catalina.bottle.1.tar.gz 🍺 /usr/local/Cellar/unixodbc/2.3.7: 46 files, 1.9MB
==> Installing php dependency: freetds
==> Pouring freetds-1.2.3.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/freetds/1.2.3: 2,072 files, 15.0MB
==> Installing php dependency: freetype
==> Pouring freetype-2.10.2.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/freetype/2.10.2: 61 files, 2.3MB
==> Installing php dependency: sqlite
==> Pouring sqlite-3.32.3.catalina.bottle.tar.gz
==> Caveats sqlite is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and
installing another version in parallel can cause all kinds of trouble.

If you need to have sqlite first in your PATH run: echo ‘export
PATH="/usr/local/opt/sqlite/bin:$PATH"’ >> ~/.zshrc

For compilers to find sqlite you may need to set: export
LDFLAGS="-L/usr/local/opt/sqlite/lib" export
CPPFLAGS="-I/usr/local/opt/sqlite/include"

==> Summary 🍺 /usr/local/Cellar/sqlite/3.32.3: 11 files, 4MB
==> Installing php dependency: python@3.8
==> Pouring python@3.8-3.8.3_2.catalina.bottle.tar.gz
==> /usr/local/Cellar/python@3.8/3.8.3_2/bin/python3 -s setup.py --no-user-cfg i
==> /usr/local/Cellar/python@3.8/3.8.3_2/bin/python3 -s setup.py --no-user-cfg i
==> /usr/local/Cellar/python@3.8/3.8.3_2/bin/python3 -s setup.py --no-user-cfg i
==> Caveats Python has been installed as /usr/local/bin/python3

Unversioned symlinks python, python-config, pip etc. pointing to
python3, python3-config, pip3 etc., respectively, have been
installed into /usr/local/opt/python@3.8/libexec/bin

You can install Python packages with pip3 install They
will install into the site-package directory
/usr/local/lib/python3.8/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> Summary 🍺 /usr/local/Cellar/python@3.8/3.8.3_2: 4,125 files, 63MB
==> Installing php dependency: glib
==> Pouring glib-2.64.4.catalina.bottle.tar.gz
==> Caveats Bash completion has been installed to: /usr/local/etc/bash_completion.d
==> Summary 🍺 /usr/local/Cellar/glib/2.64.4: 436 files, 15.7MB
==> Installing php dependency: gmp
==> Pouring gmp-6.2.0.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/gmp/6.2.0: 20 files, 3.2MB
==> Installing php dependency: libpq
==> Pouring libpq-12.3.catalina.bottle.tar.gz
==> Caveats libpq is keg-only, which means it was not symlinked into /usr/local, because conflicts with postgres formula.

If you need to have libpq first in your PATH run: echo ‘export
PATH="/usr/local/opt/libpq/bin:$PATH"’ >> ~/.zshrc

For compilers to find libpq you may need to set: export
LDFLAGS="-L/usr/local/opt/libpq/lib" export
CPPFLAGS="-I/usr/local/opt/libpq/include"

==> Summary 🍺 /usr/local/Cellar/libpq/12.3: 2,241 files, 23.8MB
==> Installing php dependency: libsodium
==> Pouring libsodium-1.0.18_1.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/libsodium/1.0.18_1: 73 files, 1012.8KB
==> Installing php dependency: libzip
==> Pouring libzip-1.7.2.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/libzip/1.7.2: 142 files, 625.2KB
==> Installing php dependency: oniguruma
==> Pouring oniguruma-6.9.5-rev1.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/oniguruma/6.9.5-rev1: 16 files, 1.3MB
==> Installing php dependency: tidy-html5
==> Pouring tidy-html5-5.6.0.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/tidy-html5/5.6.0: 14 files, 2.6MB
==> Installing php
==> Pouring php-7.4.8.catalina.bottle.tar.gz
==> /usr/local/Cellar/php/7.4.8/bin/pear config-set php_ini /usr/local/etc/php/7
==> /usr/local/Cellar/php/7.4.8/bin/pear config-set php_dir /usr/local/share/pea
==> /usr/local/Cellar/php/7.4.8/bin/pear config-set doc_dir /usr/local/share/pea
==> /usr/local/Cellar/php/7.4.8/bin/pear config-set ext_dir /usr/local/lib/php/p
==> /usr/local/Cellar/php/7.4.8/bin/pear config-set bin_dir /usr/local/opt/php/b
==> /usr/local/Cellar/php/7.4.8/bin/pear config-set data_dir /usr/local/share/pe
==> /usr/local/Cellar/php/7.4.8/bin/pear config-set cfg_dir /usr/local/share/pea
==> /usr/local/Cellar/php/7.4.8/bin/pear config-set www_dir /usr/local/share/pea
==> /usr/local/Cellar/php/7.4.8/bin/pear config-set man_dir /usr/local/share/man
==> /usr/local/Cellar/php/7.4.8/bin/pear config-set test_dir /usr/local/share/pe
==> /usr/local/Cellar/php/7.4.8/bin/pear config-set php_bin /usr/local/opt/php/b
==> /usr/local/Cellar/php/7.4.8/bin/pear update-channels
==> Caveats To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.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/7.4/

To have launchd 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: php-fpm
==> Summary 🍺 /usr/local/Cellar/php/7.4.8: 519 files, 76.1MB
==> Upgrading 5 dependents: imagemagick 7.0.10-21 -> 7.0.10-23, imagemagick 7.0.10-21 -> 7.0.10-23, imagemagick 7.0.10-21 ->
7.0.10-23, imagemagick 7.0.10-21 -> 7.0.10-23, imagemagick 7.0.10-21 -> 7.0.10-23
==> Upgrading imagemagick 7.0.10-21 -> 7.0.10-23
==> Downloading https://homebrew.bintray.com/bottles/imagemagick-7.0.10-23.catal
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/bf19ce6c826be9ab5a42d
############################################# 63.9% curl: (56) LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54 Error: Failed to download resource “imagemagick” Download failed:
https://homebrew.bintray.com/bottles/imagemagick-7.0.10-23.catalina.bottle.tar.gz
Warning: Bottle installation failed: building from source.
==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.2_3.catalin
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/80f141e695f73bd058fd8
######################################################################## 100.0%
==> Downloading https://dl.bintray.com/homebrew/mirror/ImageMagick-7.0.10-23.tar
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/882cecda27265526eb4e7
######################################################################## 100.0%
==> Installing dependencies for imagemagick: pkg-config
==> Installing imagemagick dependency: pkg-config
==> Pouring pkg-config-0.29.2_3.catalina.bottle.tar.gz 🍺 /usr/local/Cellar/pkg-config/0.29.2_3: 11 files, 623.7KB
==> Installing imagemagick
==> ./configure --disable-osx-universal-binary --prefix=/usr/local/Cellar/imagem
==> make install 🍺 /usr/local/Cellar/imagemagick/7.0.10-23: 1,497 files, 25.6MB, built in 2 minutes 4 seconds Removing:
/usr/local/Cellar/imagemagick/7.0.10-21… (1,495 files, 25.5MB)
==> Upgrading imagemagick 7.0.10-23 -> 7.0.10-23
==> Upgrading imagemagick 7.0.10-23 -> 7.0.10-23
==> Upgrading imagemagick 7.0.10-23 -> 7.0.10-23
==> Upgrading imagemagick 7.0.10-23 -> 7.0.10-23
==> Checking for dependents of upgraded formulae…
==> No broken dependents to reinstall!
==> Caveats
==> apr apr is keg-only, which means it was not symlinked into /usr/local, because Apple’s CLT provides apr.

If you need to have apr first in your PATH run: echo ‘export
PATH="/usr/local/opt/apr/bin:$PATH"’ >> ~/.zshrc

==> apr-util apr-util is keg-only, which means it was not symlinked into /usr/local, because Apple’s CLT provides apr (but not apr-util).

If you need to have apr-util first in your PATH run: echo ‘export
PATH="/usr/local/opt/apr-util/bin:$PATH"’ >> ~/.zshrc

==> libidn Emacs Lisp files have been installed to: /usr/local/share/emacs/site-lisp/libidn
==> openldap openldap is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and
installing another version in parallel can cause all kinds of trouble.

If you need to have openldap first in your PATH run: echo ‘export
PATH="/usr/local/opt/openldap/bin: P A T H " ′ > >   / . z s h r c e c h o ′ e x p o r t P A T H = " / u s r / l o c a l / o p t / o p e n l d a p / s b i n : PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/openldap/sbin: PATH">> /.zshrcechoexportPATH="/usr/local/opt/openldap/sbin:PATH"’ >> ~/.zshrc

For compilers to find openldap you may need to set: export
LDFLAGS="-L/usr/local/opt/openldap/lib" export
CPPFLAGS="-I/usr/local/opt/openldap/include"

==> curl-openssl curl-openssl is keg-only, which means it was not symlinked into /usr/local, because macOS provides curl.

If you need to have curl-openssl first in your PATH run: echo
‘export PATH="/usr/local/opt/curl-openssl/bin:$PATH"’ >> ~/.zshrc

For compilers to find curl-openssl you may need to set: export
LDFLAGS="-L/usr/local/opt/curl-openssl/lib" export
CPPFLAGS="-I/usr/local/opt/curl-openssl/include"

For pkg-config to find curl-openssl you may need to set: export
PKG_CONFIG_PATH="/usr/local/opt/curl-openssl/lib/pkgconfig"

==> libtool In order to prevent conflicts with Apple’s own libtool we have prepended a “g” so, you have instead: glibtool and glibtoolize.
==> sqlite sqlite is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and
installing another version in parallel can cause all kinds of trouble.

If you need to have sqlite first in your PATH run: echo ‘export
PATH="/usr/local/opt/sqlite/bin:$PATH"’ >> ~/.zshrc

For compilers to find sqlite you may need to set: export
LDFLAGS="-L/usr/local/opt/sqlite/lib" export
CPPFLAGS="-I/usr/local/opt/sqlite/include"

For pkg-config to find sqlite you may need to set: export
PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig"

==> python@3.8 Python has been installed as /usr/local/bin/python3

Unversioned symlinks python, python-config, pip etc. pointing to
python3, python3-config, pip3 etc., respectively, have been
installed into /usr/local/opt/python@3.8/libexec/bin

You can install Python packages with pip3 install They
will install into the site-package directory
/usr/local/lib/python3.8/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> glib Bash completion has been installed to: /usr/local/etc/bash_completion.d
==> libpq libpq is keg-only, which means it was not symlinked into /usr/local, because conflicts with postgres formula.

If you need to have libpq first in your PATH run: echo ‘export
PATH="/usr/local/opt/libpq/bin:$PATH"’ >> ~/.zshrc

For compilers to find libpq you may need to set: export
LDFLAGS="-L/usr/local/opt/libpq/lib" export
CPPFLAGS="-I/usr/local/opt/libpq/include"

For pkg-config to find libpq you may need to set: export
PKG_CONFIG_PATH="/usr/local/opt/libpq/lib/pkgconfig"

==> php To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.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/7.4/

To have launchd 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: php-fpm

MySQL 8.0.19 设置简单密码

(base) ➜ ~ mysql_secure_installation

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords and improve
security. It checks the strength of password and allows the users to
set only those passwords which are secure enough. Would you like to
setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and
special characters STRONG Length >= 8, numeric, mixed case, special
characters and dictionary file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 Please set the
password for root here.

New password:

Re-enter new password:

Estimated strength of the password: 50 Do you wish to continue with
the password provided?(Press y|Y for Yes, any other key for No) : y By
default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from ‘localhost’.
This ensures that someone cannot guess at the root password from the
network.

Disallow root login remotely? (Press y|Y for Yes, any other key for
No) :

… skipping. By default, MySQL comes with a database named ‘test’
that anyone can access. This is also intended only for testing, and
should be removed before moving into a production environment.

Remove test database and access to it? (Press y|Y for Yes, any other
key for No) :

… skipping. Reloading the privilege tables will ensure that all
changes made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No)
y Success.

All done! (base) ➜ ~ mysql -uroot -p12345678 mysql: [Warning] Using a
password on the command line interface can be insecure. Welcome to the
MySQL monitor. Commands end with ; or \g. Your MySQL connection id is
11 Server version: 8.0.19 Homebrew

Copyright © 2000, 2020, Oracle and/or its affiliates. All rights
reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input
statement.

mysql> exit Bye

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值