标签:ack sig proxy line version tar ane key org
centos 安装 nginx 教程
1.创建/etc/yum.repos.d/nginx.repo
touch /etc/yum.repos.d/nginx.repo
2.编辑
sudo vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
3.以上配置完后,执行命令查看nginx源
yum list|grep nginx
yum repolist
会看到nginx源信
4.执行安装
sudo yum -y install nginx
nginx -v查看是否安装成功
5.配置nginx
sudo vim /etc/nginx/conf.d/default.conf
把里面的location 改成如下
location / {
proxy_pass http://localhost:5000; #把80端口的访问反向代理到5000端口
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
}
检查nginx配置是否正确: sudo nginx -t
启动nginx,先进入目录
cd /usr/sbin
sudo ./nginx
6.使用下列命令来重新加载配置。
sudo nginx -s reload
sudo chown -R ec2-user:ec2-user /usr/sbin/nginx
======防火墙管理=================================
sudo yum install firewalld
firewalld的基本使用
启动:sudo systemctl start firewalld
关闭: sudo systemctl stop firewalld
查看状态: sudo systemctl status firewalld
开机禁用 : sudo systemctl disable firewalld
开机启用 :sudo systemctl enable firewalld
————————————————
sudo firewall-cmd --query-port=80/tcp 验证80端口是否打开
开启80端口
sudo firewall-cmd --add-port=80/tcp --permanent
#重启防火墙
sudo systemctl restart firewalld
--permanent #永久生效,没有此参数重启后失效
标签:ack sig proxy line version tar ane key org
原文地址:https://www.cnblogs.com/tianfengcc/p/12585267.html