Nginx安装

Nginx安装

Nginx包可在EPEL存储库中找到。

如果您没有安装EPEL存储库,可以运行以下命令:

yum install epel-release

我们现在可以通过执行以下命令来安装nginx包:

yum install nginx

安装完成后,启用并启动Nginx服务:

systemctl enable nginx
systemctl start nginx

如果您正在运行防火墙,则还需要打开端口80和443:

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload    重新载入

查看所有打开的端口:

firewall-cmd --zone=public --list-ports

永久开启一个端口:(permanent永久生效,没有此参数重启后失效)

firewall-cmd --zone=public --add-port=80/tcp --permanent 

我们现在可以检查Nginx服务的状态和版本:

systemctl status nginx

使用systemctl管理Nginx服务
1.停止Nginx服务,请运行:

sudo systemctl stop nginx

2.启动,请键入:

sudo systemctl start nginx

重新启动Nginx服务:

sudo systemctl restart nginx

在进行一些配置更改后重新加载Nginx服务:

sudo systemctl reload nginx

如果你想禁用Nginx服务在启动时启动:

sudo systemctl disable nginx

并重新启用它:

sudo systemctl enable nginx
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值