• centos7.6离线安装nginx


    nginx需要的依赖包括:gcc、g++、ssl、pcre、zlib;

    一、准备阶段


    1、查看 操作系统是否安装 gcc、gcc-c++;
    2、从 CentOS 7 镜像中,提取依赖安装包:gcc、gcc-c++;
    3、下载Nginx需要依赖的离线安装包:ssl、pcre、zlib;
    4、下载Nginx离线安装包:nginx-1.18.0.tar.gz。

    二、安装步骤

    1、安装依赖:gcc、gcc-c++、ssl、pcre、zlib。注意:一定要先安装gcc,再安装gcc-c++。然后再安装其他,其他的没有先后顺序。
    2、安装Nginx;
    3、启动Nginx(直接用默认配置启动测试即可)。

    三、详细步骤

    1、查看是否安装 gcc 

    gcc -v

    (如果已经安装 gcc ,忽略此步骤。)在 CentOS 7 的安装镜像,packages 目录,找到安装 gcc 相关的 rpm 包,并放到一个文件夹里(命名1),列表如下(注意:不同版本的操作系统,对应的rpm版本也不同):

     

     2、查看是否安装 gcc-c++ 

    gcc-c++ -v

    (如果已经安装 gcc-c++ ,忽略此步骤。)在 CentOS 7 的安装镜像,packages 目录,找到安装 gcc-c++ 相关的 rpm 包,并放到一个文件夹里(命名2),列表如下(注意:不同版本的操作系统,对应的rpm版本也不同):

     

    3、下载Nginx需要依赖的离线安装包,放到一个文件夹里(命名3)。下载地址如下:

    https://www.openssl.org/source/openssl-1.1.0i.tar.gz
    https://ftp.pcre.org/pub/pcre/pcre-8.37.tar.gz
    http://www.zlib.net/zlib-1.2.11.tar.gz

    注:默认放在/usr/local/src目录下

    4、下载Nginx离线安装包,放到文件夹1、2、3的同级目录:
    http://nginx.org/download/nginx-1.18.0.tar.gz

    四、安装

    1、安装 gcc (如果已经安装 gcc ,忽略此步骤。)
    进入到文件夹1

     rpm -Uvh *.rpm --nodeps --force

    2、安装 gcc-c++ (如果已经安装 gcc-c++ ,忽略此步骤。)
    进入到文件夹2

    rpm -Uvh *.rpm --nodeps --force

     3、解压并安装 pcre 

    cd /usr/local/src
    
    tar -zxvf pcre-8.37.tar.gz -C /usr/local
    cd /usr/local/pcre-8.37 

    .
    /configure

    make

    make install

     4、解压并安装zlib

    cd /usr/local/src
    
    tar -zxvf zlib-1.2.11.tar.gz -C /usr/local
    cd /usr/local/zlib-1.2.11 

    .
    /configure

    make

    make install

     5、解压并安装 openssl 

    cd /usr/local/src
    
    tar -zxvf openssl-1.1.0i.tar.gz -C /usr/local
    
    cd /usr/local/openssl-1.1.0i
    
    ./config
    
    make
    
    make install

     6、解压并安装 Nginx 

    cd /usr/local/src
    
    tar -zxvf nginx-1.18.0.tar.gz
    
    cd nginx-1.18.0
    
    ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-pcre=/usr/local/pcre-8.37 --with-zlib=/usr/local/zlib-1.2.11 --with-openssl=/usr/local/openssl-1.1.0i
    make

    make install

    --prefix=path

    defines a directory that will keep server files. This same directory will also be used for all relative paths set by configure (except for paths to libraries sources) and in the nginx.conf configuration file. It is set to the /usr/local/nginx directory by default.

    --with-pcre=path

    sets the path to the sources of the PCRE library. The library distribution (version 4.4 — 8.43) needs to be downloaded from the PCRE site and extracted. The rest is done by nginx’s ./configure and make. The library is required for regular expressions support in the location directive and for the ngx_http_rewrite_module module.

    --with-zlib=path

    sets the path to the sources of the zlib library. The library distribution (version 1.1.3 — 1.2.11) needs to be downloaded from the zlib site and extracted. The rest is done by nginx’s ./configure and make. The library is required for the ngx_http_gzip_module module.

    7、启动Nginx(直接用默认配置启动测试即可)

    cd /usr/local/nginx/sbin
    .
    /nginx

    8、开放端口

    默认防火墙应该都是开启的,因此需要开放端口。如果防火墙未开启,以下步骤忽略。

    查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

    firewall-cmd --state

    开放nginx默认使用的80端口,并重启防火墙

    firewall-cmd --query-port=80/tcp
    
    firewall-cmd --permanent --add-port=80/tcp

    service firewalld restart

    9、测试

    浏览器打开,输入IP地址即可,默认使用80端口。

    10、查看Nginx进程

    ps -ef|grep nginx

    11、停止Nginx

    ./nginx -s stop

    五、参考

    1、https://blog.csdn.net/achi010/article/details/106392040

    2、https://blog.csdn.net/MyMBS/article/details/90719902

    3、https://www.cnblogs.com/hanzhi/articles/11482263.html

               4、http://nginx.org/en/docs/configure.html

  • 相关阅读:
    加法&除法
    [转] KMP算法
    软件测试视频集
    集成测试的目的和意义
    UNIX常用命令简介
    软件测试V模型
    集成测试、单元测试与系统测试的差别
    软件测试的基本概念和方法
    软件测试工程师 笔试题
    软件测试
  • 原文地址:https://www.cnblogs.com/tesila/p/15236024.html
Copyright © 2020-2023  润新知