安装 Nginx
yum 安装 nginx 非常简单,就输入一条命令即可。
sudo yum -y install nginx # 安装 nginx |
使用 yum
进行 Nginx 安装时,Nginx 配置文件在 /etc/nginx
目录下。
使用 wget
进行 Nginx 安装时,Nginx 配置文件在 /usr/local/nginx/conf
目录下。
具体的命令
vim /etc/nginx/nginx.conf # 查看nginx配置内容 |
防火墙设置
如果你的服务器开启了防火墙,则需要同时打开 80(HTTP)和 443(HTTPS)端口
firewall-cmd --zone=public --add-port=443/tcp --permanent |
如果后续安装了Apache,会与Nginx冲突,导致Nginx关闭。查看Nginx运行状态时会出现红字报错:
Failed to start The nginx HTTP and reverse proxy server.如果想恢复,需要先执行下面两条命令关闭Apache:
systemctl stop httpd
systemctl disable httpd然后重启Nginx:
sudo systemctl restart nginx