• Liunx软件安装之Nginx


    安装 Nginx

    1. 添加 Nginx 到 YUM 源
    sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    

    2)yum 安装

    yum install nginx
    
    1. 启动Nginx
    sudo systemctl start nginx.service
    

    出现上图,表示安装成功。

    设置开机自启动

    除了之前设置开机脚本外,我们也可以通过 systemctl enable 命令 来实现开机自启动服务。

    systemctl enable nginx.service  # 设置开机自启动
    systemctl disable nginx.service	# 关闭开机自启动
    

    相关配置文件路径

    网站文件存放默认目录

    /usr/share/nginx/html
    

    网站默认站点配置

    /etc/nginx/conf.d/default.conf
    

    自定义Nginx站点配置文件存放目录

    /etc/nginx/conf.d/
    

    Nginx全局配置

    /etc/nginx/nginx.conf
    

    简单反向代理配置

    我们这边将 nginx 默认页面转为 tomcat 默认项目的页面即:输入 http://localhost 显示 http://localhost:8080 页面内容

    1. 编辑 default.conf 文件
    vim /etc/nginx/conf.d/default.conf 
    

    将 location 标签编辑成如下内容:

    # location / {
    #    root   /usr/share/nginx/html;
    #    index  index.html index.htm;
    # }
     location / {
         proxy_pass http://localhost:8080;
         proxy_set_header Host  $http_host;
         proxy_set_header X-Real-IP  $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     }
    

    2)重启 nginx 服务,并刷新页面

    systemctl restart nginx
    

    可以看到已经将默认的网页转到 tomcat 默认项目上了

  • 相关阅读:
    02-链路层
    01-TCP/IP概述
    ARM Cortex-A9 (tiny 4412)
    STM32 f407 温湿度采集报警
    arduino mega 避障报距小车
    归纳法调试
    python 数据类型Ⅲ(字典)
    Python 数据类型Ⅱ(列表,元祖)
    Python 数据类型(str,int,bool)
    Python while循环&格式化输出&运算符
  • 原文地址:https://www.cnblogs.com/markLogZhu/p/11399953.html
Copyright © 2020-2023  润新知