【已经验证】安装Nginx 参考地址:https://phoenixnap.com/kb/how-to-install-nginx-on-centos-7

 

NGINX -- 安装

  • 将系统存储库更新到最新的CentOS版本
    • 【更新命令】yum -y upgrade =======》-y 是可选的“确认”参数
  • 为Enterprise Linux安装额外软件包---EPEL
    • yum install -y epel-release =======》epel 免费提供很多免费开源包
  • 安装NGINX
    • yum -y install nginx
  • 禁用Apache并启动NGINX(如果已经运行了Apache服务器,则需要在启动NGINX之前将其禁用。)
    • service httpd stop
    • systemctl disable httpd ======》禁用Apache将导致任何当前托管的网站崩溃。您禁用了Apache,但它仍可能在服务器重启期间自动启动。通过运行该命令禁用自动启动。
    • 您禁用了Apache,但它仍可能在服务器重启期间自动启动。通过运行以下命令禁用自动启动:
  • 启动NGINX
    • systemctl start nginx
  • 检查NGINX运行状态
    • system status nignx
  • NGINX --开机自启动
    • systemctl enable nginx
  • 防火墙 -- 设置 (CentOS 7默认启用防火墙,并阻止访问端口80和443.它将阻止来自NGINX的任何入站HTTPS和HTTP数据包。要允许HTTP和HTTPS流量)
    • firewall-cmd --zone=public --permanent --add-service=http
    • firewall-cmd --zone=public --permanent --add-service=https
    • firewall-cmd --reload
  • NGINX -- 验证安装
    • 浏览器中输入 IP 地址,看是否有NGINX欢迎页面
  • 测试失败的错误消息

  • 默认NGINX服务器根目录
  • 全局配置
  • 管理NGINX - 基本任务
    • 停止NGINX
      • systemctl stop nginx
    • 重启NGINX
      • systemctl restart nginx
    • 修改配置后重启NGINX
      • systemctl reload nginx
    • 启动时禁止自动启动NGINX
      • systemctl disable nginx
  • 配置新目录
  • 结合guniorn部署flask应用时,/etc/nginx.conf文件的配置如下:
    •  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值