• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

安利:华为鲲鹏920云主机部署Nginx服务器一键拉起自动化脚本

互联网 diligentman 2小时前 2次浏览

需求:
华为鲲鹏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


打完收工!

睡觉了,晚安!


喜欢 (0)