一 . 安装nginx
yum install -y nginx
安装成功后默认网站目录: /usr/share/nginx/html
默认的配置文件:/etc/nginx/nginx.conf
二. 防火墙放开端口80和443
如果你的服务器打开了防火墙,你需要运行下面的命令,打开80和443端口。
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
如果是阿里云服务器,需要打开安全组,放开80和443端口
三. Nginx的常规操作
1.启动 Nginx
systemctl start nginx
2.停止 Nginx
systemctl stop nginx
3.重启 Nginx
systemctl restart nginx
4.重载 Nginx
systemctl reload nginx
5.查看Nginx状态
systemctl status nginx
6.启用开机启动Nginx
systemctl enable nginx
7.禁用开机启动Nginx
systemctl disable nginx