一、配置 EPEL源
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/
三、开启端口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
四、操作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
网友评论