• linux nginx 安装


    一、安装依赖(安装过的跳过)

    yum -y install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl-devel

    二、下载nginx稳定版

    wget http://nginx.org/download/nginx-1.16.1.tar.gz

    或者去nginx官网下载 下载完成后上传到服务器

    三、解压–编译–安装

    1. 解压
      tar -zxvf nginx-1.16.1.tar.gz
    2. 进入解压目录
      cd nginx-1.16.1/
    3. 编译
      # 需要使用https执行指令
      ./configure --with-http_ssl_module
      # 不需要使用https执行
      ./configure
      • 编译如果提示./configure: error: the HTTP rewrite module requires the PCRE library.,则执行yum -y install pcre-devel后重新编译
      • 提示./configure: error: the HTTP gzip module requires the zlib library.,则执行yum install -y zlib-devel后重新编译
      • 提示SSL modules require the OpenSSL library,则执行yum -y install openssl openssl-devel make zlib zlib-devel gcc gcc-c++ libtool    pcre pcre-devel

    4. 安装
      make && make install

    五、nginx服务的启动操作

    cd /usr/local/nginx/sbin

    # 默认配置文件启动

    ./nginx

    # 指定配置文件启动

    ./nginx -c /usr/local/nginx/conf/nginx.conf

    停止

    cd /usr/local/nginx/sbin

    # 停止指令

    ./nginx -s stop

    六、开机启动nginx

    编辑文件/etc/rc.d/rc.local在后面添加内容

    vi /etc/rc.d/rc.local

    内容

    /usr/local/nginx/sbin/nginx

    ll查看下rc.local文件,如果不是绿色表示没有执行权限,则执行指令chmod +x /etc/rc.d/rc.local

    PS:直接使用nginx指令,提示未找到命令

    1. 编辑/etc/profile文件vi /etc/profile在末尾处添加
      PATH=$PATH:/usr/local/nginx/sbin
      export PATH
    2. 执行source /etc/profile指令
  • 相关阅读:
    Flink学习笔记
    Unable to connect to the server: x509: certificate signed by unknown authority
    network plugin is not ready: cni config uninitialized
    springBoot中文件上传功能Api
    老技术js实现iframe刷新
    JetBrains 里不为人知的秘密(16)Rider添加索引
    C++类的成员变量赋初值问题
    计算两个box的IOU
    C++ error: use of deleted function
    C++模板函数偏特化方法
  • 原文地址:https://www.cnblogs.com/Denny_Yang/p/16362248.html
Copyright © 2020-2023  润新知