安装
- 配置EPLE源
sudo yum install -y epel-release
sudo yum -y update
- 安装Nginx
sudo yum install -y nginx
安装后:
默认网站目录:/usr/share/nginx/html
默认的配置文件为:/etc/nginx/nginx.conf
自定义配置文件目录为:/etc/nginx/conf.d/
日志文件路径:/var/log/nginx
- 开启80和443端口或者关闭防火墙
如果你的服务器打开了防火墙,你需要运行下面的命令,打开80和443端口。
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
关闭防火墙
systemctl stop firewalld
操作Nginx
- 启动Nginx
systemctl start nginx
- 停止Nginx
systemctl stop nginx
- 重启Nginx
systemctl restart nginx
- 查看Nginx状态
systemctl status nginx
- 开机启动Nginx
systemctl enable nginx
- 禁用开机启动Nginx
systemctl disable nginx