後臺管理系統,前端框架用什麼最好?
一、伺服器
1、CentOS
2、Ubantu
二、FTP工具
1、FileZilla(Win)
2、ForkLift(Mac)
公網IP
三、連線方式
1、遠端連線
2、xshell
3、terminal
```
ssh [email protected]
輸入密碼
修改know_hosts
```
四、包管理器
OS 檔案格式 工具
1、Ubuntu .deb apt,apt-cache,apt-get,dpkg
2、CentOS .rpm yum
五、更新包並安裝nginx
1、更新所有包
apt-get
同步 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的索引
apt-get update
2、安裝nginx
apt-get install nginx
3、檢視程序
ps aux | grep nginx
process /usr/sbin/nginx -g daemon on; master-process on;
4、訪問公網IP,驗證nginx是否安裝ok
ls -l /etc/nginx 預設安裝路徑
六、nginx
1、安裝
2、配置自啟動
3、systemd開啟關閉nginx
4、nginx.conf配置
5、遠端拷貝
6、linux中許可權管理
7、前臺專案nginx部署
8、****sh編寫啟動指令碼
9、配置啟動、重載入命令的指令碼地址
nginx -t 預啟動,檢查nginx狀態
systemctl restart nginx 重啟nginx服務,重操作
systemctl reload nginx 使配置資訊生效,推薦
10、curl命令
eg: curl -I www.baidu.com
curl -I www.baidu.com > index.html
curl -I -H "Accept-Encoding:gzip,deflate" https://hectorstatic.baidu.com/cd37ed75a9387c5b.js?_=1614424501009
11、配置不同檔案的MIME型別
http {
types {
text/html html;
text/css css;
}
include mime.types
}
/etc/nginx/mime.types
11、return and rewrite
rewrite ^/user/(w+) /greet/$1
12、echo '' > access.log
echo '' > error.log
13、處理php檔案
location ~\.php$ {
include fastcgi.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
14、配置工作程序
ps aux | grep nginx
worker_processes auto;
nproc // 查詢系統核數
ulimit -n 查詢最大可開啟檔案數
events {
worker_connections 65535
}
// 最大併發數 = 工作程序 * 最大可開啟檔案數
15、效能調優-緩衝
// 設定request body的快取大小,如果超過閾值,那麼整個body或者部分body將會被寫入一個臨時檔案,nginx如果使用檔案緩衝,則此配置無效
32位系統預設8K, 64位預設16K
client_body_buffer_size 10K;
// 設定Nginx可以處理的最大request body大小。如果收到的請求大於閾值,Nginx會回覆HTTP 413錯誤
(Request Entity too large),如果web伺服器提供大檔案上傳的話,最好設定這個指令,Nginx預設大小為1M
client_max_body_size 8m;
// 類似client_body_buffer_size 它給request_header分配快取,預設1K
client_header_buffer_size 1K;
16、效能調優-超時
// 客戶端與伺服器建立連線後傳送request body的超時時間,如果超過閾值未傳送任何內容,Nginx返回HTTP 408錯誤,預設為60s
client_body_timeout 12;
client_header_timeout 12;
// 設定keepalive連線的超時時間,預設為65秒,若將它設定為0,就禁止了keepalive連線
keepalive_timeout 15;
// 指定向客戶端傳輸資料的超時時間,預設為60秒
send_timeout 10;
// 開啟檔案高效傳輸模式
sendfile on;
// 防止網路及磁碟I/O阻塞,提升Nginx工作效率
tcp_nopush on;
17、動態模組
需要單獨引入
18、gzip壓縮
gzip on;
gzip_comp_level 3; #1~9
gzip_types text/css text/javascript; # 進行壓縮的檔案型別
19、HTTPS配置
# 生成祕鑰
openssl req -x509 -nodes -days 10 -newkey rsa:2048 -keyout /etc/ngnx/ssl/self.key -out /etc/nginx/ssl/self.crt
listen: 443 ssl;
# 配置證書
ssl_certificate /etc/nginx/ssl/self.crt
ssl_certicate_key /etc/nginx/ssl/self.key
20、跳轉安全連結
21、server push
location
22、基礎授權
23、反向代理
24、負載均衡
測試:while sleep 0.5: do curl http://localhost:8000;done
# 配置伺服器組 upstream node_servers { server localhost:5001; server localhost:5002; server localhost:5003; } server { listen 8888; location / { # 反向代理到伺服器組 proxy_pass http://node_servers; } }
25、永久開啟node服務
npm install forever -g
forever start index.js
or
npm install pm2 -g