需求:
華為鯤鵬920云主機部署Nginx服務器
要求撰寫一鍵拉起自動化腳本
撰寫腳本
vim nginx-run.sh
#!/bin/bash
# blog:閉關苦煉內功(https://blog.csdn.net/frdevolcqzyxynjds) 2021-06-10 01:07
echo "============================開始安裝Nginx===================================" &&
rpm -qa | grep nginx &&
gcc -v &&
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel &&
cd /opt/ &&
wget http://nginx.org/download/nginx-1.19.9.tar.gz &&
tar -C /usr/local/ -zxf nginx-1.19.9.tar.gz &&
cd /usr/local/nginx-1.19.9/ &&
./configure && make && echo '===========' && make install &&
cat<<EOF> /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
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 quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
ps -ef | grep nginx &&
systemctl status nginx &&
systemctl enable nginx &&
systemctl status nginx &&
systemctl start nginx &&
systemctl status nginx &&
ps -ef | grep nginx &&
echo "============================Nginx安裝成功!已啟動!==================================="
授權腳本可執行權限
chmod u+x nginx-run.sh
執行腳本,一鍵拉起Nginx服務
./nginx-run.sh
打完收工!
睡覺了,晚安!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/286863.html
標籤:其他
上一篇:docker代理配置詳解
