相关文章:
Nginx 官方文档:Installing NGINX Open Source
CentOS 使用 Nginx 实现 同一台服务器 多域名 对应 多项目
- 安装 EPEL:
yum -y install epel-release
- 安装 EPEL 后更新系统:
yum -y update
- 安装 Nginx:
yum -y install nginx
- 查看 Nginx 版本:
[root@CentOS-7-x86-64-DVD-1810 ~]# nginx -v nginx version: nginx/1.12.2
- 打开 http 服务(80端口):
或:firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
- 重新加载防火墙:
或重启防火墙(不推荐,防火墙将出现中断):firewall-cmd --reload
systemctl restart firewalld
- 查看已开启的服务(端口):
firewall-cmd --list-all
- 启动 Nginx:
systemctl start nginx
- 查看 Nginx 状态:
systemctl status nginx
- 开启 Nginx 开机自启:
systemctl enable nginx
- 查看 Nginx 开机自启状态:
systemctl list-unit-files | grep nginx
- 访问效果:
- 查找 Nginx 配置文件:
[root@CentOS-7-x86-64-DVD-1810 ~]# find / -name nginx.conf /etc/nginx/nginx.conf