安装nginx
#!/bin/bash
[ $(id -u) != "0" ]&& echo "error,not root user" && exit 1
echo "-------------配置yum的软件仓库-------------"
sudo yum install epel-release
echo "-------------安装nginx-------------"
sudo yum install -y nginx
echo "-------------开启nginx-------------"
sudo systemctl start nginx
echo "-------------配置开机启动-------------"
sudo systemctl enable nginx
echo "-------------查看nginx服务状态-------------"
sudo systemctl status nginx
卸载nginx
#!/bin/bash
echo "==============停止nginx服务=============="
sudo systemctl start nginx
echo "==============删除nginx自启动配置=============="
chkconfig nginx off
echo "==============删除nginx配置文件=============="
rm -rf /usr/sbin/nginx
rm -rf /etc/nginx
rm -rf /etc/init.d/nginx
echo "==============remove nginx=============="
yum remove -y nginx
EXISTS_RPMS=`rpm -qa | grep -i nginx`
if [[ $EXISTS_RPMS = "" ]]
then
echo "==============nginx卸载完成=============="
else
for RPM in ${EXISTS_RPMS}
do
rpm -e --nodeps ${RPM}
done
fi