【已经验证】安装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文件的配置如下:
发布了10 篇原创文章 · 获赞 1 · 访问量 2045

猜你喜欢

转载自blog.csdn.net/xinxianren007/article/details/94946977