Center OS nginx卸载、安装

1.安装

1.1添加Nginx存储库

    要添加CentOS EPEL仓库,终端使用yum命令安装,直接复制执行:

sudo yum -y install epel-release

1.2:安装Nginx

现在Nginx存储库已经安装在您的服务器上,使用以下yum命令安装Nginx :

sudo yum -y install nginx

1.3:启动Nginx

Nginx不会自动启动.要运行Nginx,请输入:

sudo systemctl start nginx

1.4:设置防火墙

 1.4.1:允许http通信
sudo firewall-cmd --permanent --zone=public --add-service=http
1.4.2:允许https通信
sudo firewall-cmd --permanent --zone=public --add-service=https
1.4.3:重启防火墙
sudo firewall-cmd --reload

1.5:测试

浏览器里键入你的主机地址

如果看到这个页面,那么你的Web服务器现在已经正确安装了。

  如果想在系统启动时启用Nginx。请输入以下命令:

sudo systemctl enable nginx

恭喜你!!! Nginx现在已经成功安装并允许了!!

二 . 卸载

1:停止Nginx软件

service nginx stop

2:删除Nginx的自动启动

chkconfig nginx off

3:从源头删除Nginx

rm -rf /usr/sbin/nginx
rm -rf /etc/nginx
rm -rf /etc/init.d/nginx

4:再使用yum清理

yum remove nginx

ok结束。

原文地址:https://www.cnblogs.com/o0zhangzh0o/p/12979433.html