centOS安装nginx服务
一、配置 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/
三、开启端口
3.1、普通服务器
打开默认80、443端口
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
3.2、云服务器
通过控制台安全组自行添加端口
四、操作 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