centOS7.4安装nginx

参考原文地址:https://blog.csdn.net/oldguncm/article/details/78855000


第一步 - 添加Nginx存储库

要添加CentOS 7 EPEL仓库,请打开终端并使用以下命令:

sudo yum install epel-release

第二步 - 安装Nginx

现在Nginx存储库已经安装在您的服务器上,使用以下yum命令安装Nginx 

sudo yum install nginx

在对提示回答yes后,Nginx将在服务器上完成安装。

第三步 - 启动Nginx

Nginx不会自行启动。要运行Nginx,请输入:

sudo systemctl start nginx

如果您正在运行防火墙,请运行以下命令以允许HTTP和HTTPS通信:

sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
常用命令:启动:sudo systemctl start nginx关闭:sudo systemctl stop nginx重启:sudo systemctl restart nginx查看版本:nginx -v访问nginx,现在你可以通过公网ip (本地可以通过 localhost /或 127.0.0.1 ) 查看nginx 服务返回的信息。
curl -i localhost 修改端口:配置文件在

vi /etc/nginx/nginx.conf

修改默认端口80位8089

重启nginx

sudo systemctl restart nginx

防火墙配置 8089端口

firewall-cmd --zone=public --add-port=8089/tcp --permanent

重启防火墙

firewall-cmd --reload


阿里云在安全组配置规则中也要添加对应的端口



启动:

猜你喜欢

转载自blog.csdn.net/ky1in93/article/details/80131489