背景:Linux系统
一 更新一下yum
sudo yum install -y epel-release
sudo yum -y update
二、安装 Nginx
sudo yum install -y nginx
安装成功后,默认的网站目录为: /usr/share/nginx/html
(把个人网站放在这个目录下就可以了访问到了,不加文根默认访问的是index.nginx-debian.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
版权声明:本文为weixin_43576024原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。