茜之蘭地鬼播報2022.4.4
阿新 • • 發佈:2022-04-04
- 下載nginx
- 下載依賴
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel pcre pcre-devel
- 將下載好的nginx上傳至伺服器
- 解壓,編譯,安裝
# 解壓
tar zxvf nginx-1.21.6.tar.gz
# 進入nginx安裝包
cd nginx-1.21.6
# 原始碼安裝,自定義安裝位置
./configure --prefix=/usr/local/nginx
# 編譯安裝
make
make install
- 安裝成系統服務
vi /usr/local/systemd/system/nginx.service #指令碼內容 [Unit] Description=nginx - web server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s stop ExecQuit=/usr/local/nginx/sbin/nginx -s quit PrivateTmp=true [Install] wantedBy=multi-user.target
- 重新載入系統服務
systemctl daemon-reload
- 基本命令
# 開機自啟
systemctl enable nginx
# 啟動
systemctl start nginx
# 重新啟動
systemctl restart nginx
# 關閉
systemctl stop nginx
# 檢視執行狀態
systemctl status nginx