Homebrew是一款Mac OS平臺下的軟件包管理工具,linux沒法裝!!!!!!!
安裝
#macos會自帶安裝ruby腳本
[root@mango-2020-000101 bin]# ruby -v
#新建一個homebrew的安裝目錄/usr/local/homebrew
[root@mango-2020-000101 bin]# /usr/local/homebrew -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
使用
#查看本機brew版本
$ brew -v
#brew幫助信息
$ brew -h
#查看本機使用 brew所安裝的程序
$ brew list
#搜索網絡上 brew 所管理程序
$ brew search mysql
#搜索網絡上 brew 所管理程序 的mysql的詳細信息
$ brew info mysql
#使用 brew 安裝mysql 默認使用brew安裝的所有軟件在 /usr/local/cellar 下
$ brew install mysql
#如果出現程序一直卡在Updating Homebrew... 這一步驟,那我們可以使用control + c 取消本次更新
# 啓動
$ brew services start mysql
# 重啓
$ brew services restart mysql
# 停止
$ brew services stop mysql
#查看本機使用 brew所安裝的程序
$ brew list
#卸載本機使用 brew所安裝的mysql
$ brew uninstall mysql
mysql的下載包在/usr/local/Cellar 並且在其他地方會建立類似快捷方式的引用鏈接(如/usr/local/opt)
注意
上圖卸載時候多了一個/ 斜槓 會報錯
使用
# 安裝後配置文件默認在 /usr/local/etc/nginx nginx.conf
# 配置文件默認服務地址:訪問http://localhost:8080
# 檢測配置文件內容正確性
$ nginx -t
# 刷新配置文件
$ nginx reload
# 產看版本
$ nginx -v
# 啓動 訪問http://localhost:8080
$ brew services start nginx
# 重啓 訪問http://localhost:8080
$ brew services restart nginx
# 停止
$ brew services stop nginx
# nginx.conf 文件內容如下
# 最大連接數=1024*3=3072
# 運行用戶
user wangwenjian;
# 程序進程數,建議設置爲等於CPU總核心數
worker_processes 3;
# 錯誤日誌路徑及級別 [debug|info|notice|warn|error|crit]
error_log /var/log/nginx/error.log warn;
# 進程文件
pid /var/run/nginx.pid;
# 工作模式及連接數上限
events {
# epoll是多路複用IO(I/O Multiplexing)的一種方式,但僅用於linux2.6以上內核,提升性能
use epoll;
# 單個進程最大連接數
worker_connections 1024;
};
# 最大文件打開數(連接)。可不設置或設置爲系統優化後的ulimit -HSn的結果
worker_rlimit_nofile 51200;
# 設定http服務器,利用它的反向代理功能提供負載均衡支持
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
#配置1 監聽80端口,這個server 不寫也默認存在的
server {
#server_name localhost;
listen 80;
}
#配置2 監聽89端口
server {
#server_name localhost;
listen 89;
# 訪問 ip:89/ 轉發到百度
location / {
proxy_pass http://www.baidu.com/;
}
# 訪問 ip:89/sina/ 直接轉發到新浪,不使用負載均衡
location /sina/ {
proxy_pass https://www.sina.com/;
}
# 訪問 ip:89/163/ 轉發到網易,使用負載均衡
location /163/ {
proxy_pass https://163_pool;
}
}
#網易負載均衡池,可以配置多個服務,權重,輪訓
upstream 163_pool{
server https://www.163.com/ weight=1 max_fails=2 fail_timeout=30s;
server https://www.163.com/;
server https://www.163.com/;
}
}