CentOS 7下安装Nginx

Krent
2022-03-30 / 0 评论 / 57 阅读 / 正在检测是否收录...

一、配置 EPEL 源

yum install -y epel-release

二、安装 Nginx

yum install -y nginx

安装成功后,默认的网站目录为: /usr/share/nginx/html

默认的配置文件为:/etc/nginx/nginx.conf

自定义配置文件目录为: /etc/nginx/conf.d/

三、开启端口 80 和 443

如果你的服务器打开了防火墙,你需要运行下面的命令,打开 80 和 443 端口。

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

四、操作 Nginx

# 1.启动 Nginx
systemctl start nginx

# 2.停止 Nginx
systemctl stop nginx

# 3.重启 Nginx
systemctl restart nginx

# 4.查看 Nginx 状态
systemctl status nginx

# 5.开机启动 Nginx
systemctl enable nginx

# 6.禁用开机启动 Nginx
systemctl disable nginx

输入IP或者域名到浏览器,打开页面如下:
centos-7-nginx.png

0

评论 (0)

取消