Homebrew
在线安装
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
国内在线安装
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
安装结束的提示
==> nginx
Docroot is: /opt/homebrew/var/www
The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in /opt/homebrew/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
❯
Mysql
搜索
brew search mysql
安装
brew install mysql@5.7
安装结果提示
=> Pouring mysql@5.7-5.7.32.arm64_big_sur.bottle.2.tar.gz
==> /opt/homebrew/Cellar/mysql@5.7/5.7.32/bin/mysqld --initialize-i
==> Caveats
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
mysql@5.7 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.
If you need to have mysql@5.7 first in your PATH, run:
echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
For compilers to find mysql@5.7 you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/mysql@5.7/lib"
export CPPFLAGS="-I/opt/homebrew/opt/mysql@5.7/include"
To have launchd start mysql@5.7 now and restart at login:
brew services start mysql@5.7
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/mysql@5.7/bin/mysql.server start
==> Summary
🍺 /opt/homebrew/Cellar/mysql@5.7/5.7.32: 319 files, 233.7MB
Homebrew 安装 PHP
brew search php
brew install php@7.3
安装后的提示:
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php@7.3/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.3/
php@7.3 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have php@7.3 first in your PATH, run:
echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.3/sbin:$PATH"' >> ~/.zshrc
For compilers to find php@7.3 you may need to set:
export LDFLAGS="-L/usr/local/opt/php@7.3/lib"
export CPPFLAGS="-I/usr/local/opt/php@7.3/include"
To have launchd start php@7.3 now and restart at login:
brew services start php@7.3
Or, if you don't want/need a background service you can just run:
php-fpm
==> Summary
🍺 /usr/local/Cellar/php@7.3/7.3.28_1: 521 files, 77.3MB
==> Caveats
==> php@7.3
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php@7.3/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.3/
php@7.3 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have php@7.3 first in your PATH, run:
echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.3/sbin:$PATH"' >> ~/.zshrc
For compilers to find php@7.3 you may need to set:
export LDFLAGS="-L/usr/local/opt/php@7.3/lib"
export CPPFLAGS="-I/usr/local/opt/php@7.3/include"
To have launchd start php@7.3 now and restart at login:
brew services start php@7.3
Or, if you don't want/need a background service you can just run:
php-fpm
Homebrew 安装 MySQL
brew search mysql
brew install mysql@5.7
ll /opt/homebrew/opt/mysql@5.7/bin
echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
mysql
mysql --version
cd mysql@5.7
切换为超级管理员
sudo su
进入mysql安全模式
./mysqld_safe --skip-grant-tables &
直接输入 ./mysql 在安全模式下启动 mysql
./mysql
进入后修改密码。以下是在 mysql 命令行操作:
show databases;
use mysql;
update user set authentication_string=PASSWORD("自定义密码") where user='root';
update user set plugin="mysql_native_password";
(这句话需要先检查下 plugin 字段是不是 mysql_native_password)
flush privileges;
quit;
源码安装 Redis
mkdir redis && cd redis
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
cd redis-stable
make
make test
sudo make install
sudo ./install_server.sh
Please select the redis executable path [/usr/local/bin/redis-server]
Selected config:
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Mmmmm... the default config is missing. Did you switch to the utils directory?
使用 HomeBrew 安装 Redis
~/apps/redis ❯ brew install redis
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/redis-6.2.3.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Pouring redis-6.2.3.big_sur.bottle.tar.gz
==> Caveats
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
==> Summary
🍺 /usr/local/Cellar/redis/6.2.3: 13 files, 2.0MB
安装 phpredis 扩展
git clone https://www.github.com/phpredis/phpredis.git
cd phpredis
phpize && ./configure && make && sudo make install
【如果有多个php,需要指定 phpize 和 php-config】
./configure --with-php-config=/usr/local/php-config --enable-redis-igbinary=no --enable-redis-lzf=no --enable-redis-zstd=no
php --ini 查看 php.ini 路径
在 php.ini 里加 extension=redis
重启php:brew services start php@7.4
重新加载nginx:sudo nginx -s reload
重启php-fpm
安装 nginx
~/apps/redis/phpredis develop ?3 ❯ brew install nginx 18:51:53
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/nginx-1.21.0.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Pouring nginx-1.21.0.big_sur.bottle.tar.gz
==> 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.21.0: 25 files, 2.2MB
安装 swoole 扩展
pecl install swoole
openssl指定其位置
enable sockets supports? [no] : yes
enable openssl support? [no] : yes --with-openssl-dir=/usr/local/opt/openssl@1.1
... ...
安装 phlcon 扩展
https://gitee.com/mirrors/cphalcon/tree/v3.4.4
cd cphalcon/build
./install
安装 mq 扩展
pecl install amqp
安装 composer
brew install composer