zoukankan      html  css  js  c++  java
  • ubuntu16.04 离线安装nginx

    场景描述:

    客户生产环境服务器,内网隔离无法访问互联网,需要准备好相应的安装包,离线部署。

    服务器&软件包版本:

    环境:
    ubunt16.04 
    gcc-4.8.4 
    包:
    nginx-1.8.1
    pcre-8.38
    zlib-1.2.11
    openssl-1.0.2n

    不想自己下载的小伙伴,可以从如下链接下载上述4个包:

    https://pan.baidu.com/s/1K_1Bbz_zcGKvvTljCZcwSQ 提取码: 2tj5 

    前置环境配置,也是安装成功的前提,即将上述相应安装包都上传复制到/usr/local 目录下。

    需要用切换到root用户操作,进入到 /usr/local 目录下执行下面1 2 3 4 5 6步骤,此处路径与之后安装nginx对应,需要注意!

    1. gcc --源码编译依赖的环境,必须保证系统已安装该包

    apt-get install build-essential
    apt-get install libtool
    // gcc --version 查看gcc版本
    // gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

    2. PCRE ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

    PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式

    wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
    tar -zxvf pcre-8.38.tar.gz
    cd pcre-8.38
    ./configure  
    make  
    make install 

    3. zlib http://zlib.net

    zlib库提供了很多种压缩和解压缩的方式,nginx使用zlib对http包的内容进行gzip

    wget http://zlib.net/zlib-1.2.11.tar.gz
    tar -zxvf zlib-1.2.11.tar.gz 
    cd zlib-1.2.11
    ./configure  
    make 
    make install 

    4. penssl https://www.openssl.org/source/

    OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用. 

    nginx不仅支持http协议,还支持https(即在ssl协议上传输http)

    wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz
    tar -zxvf openssl-1.0.2n.tar.gz

    5. 安装步骤nginx

    一、源码安装

    1.下载 nginx 压缩包

    wget https://nginx.org/download/nginx-1.8.1.tar.gz

    2.解压 nginx-1.8.1.tar.gz

    tar -zxvf nginx-1.8.1.tar.gz

    3.解压后 我们通过 cd 命令进入到nginx-1.8.1文件夹下面

    安装nginx到 /usr/local/nginx目录下

    cd nginx-1.8.1

    // 配置nginx
    ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/pcre-8.38 --with-zlib=/usr/local/zlib-1.2.11 --with-openssl=/usr/local/openssl-1.0.2n
    // 编译
    make
    // 安装
    make install

    至此nginx安装完成!

    如果使用 nginx 访问 ftp 站点内容,需要将 nginx user设置为对应 ftp user 不然会因权限不足报 403 错误

     6.启动nginx

    建议使用第一种启动,否则可能会出现如下错误【nginx: [error] open() "/***/***/***/nginx.pid" failed (2: No such file or directory)】

    第一种启动方式:
    cd /usr/local/nginx
    ./nginx -c ./nginx.conf
    
    第二种启动方式:
    /usr/local/nginx/nginx
    cd /usr/local/nginx 目录下:启动
    ./nginx -c ./nginx.conf
    
    重新加载配置
    ./nginx -s reload
    
    停止:
    ./nginx -s stop

    附ubuntu在线安装nginx的方式:

    该方式安装完成后,目录及配置文件,以及启动方式跟离线版编译安装的结果会有所区别。

    apt-get install nginx
    启动程序文件在/usr/sbin/nginx
    
    日志放在了/var/log/nginx中,分别是access.log和error.log
    并已经在/etc/init.d/下创建了启动脚本nginx
    
    在线安装启动nginx
    /etc/init.d/nginx start

    nginx配置参数说明:

    https://www.cnblogs.com/jason007/articles/9400505.html

    https://blog.csdn.net/qq_33516288/article/details/77197110

  • 相关阅读:
    BZOJ1527 : [POI2005]Pun-point
    2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016)
    2016-2017 ACM-ICPC Northwestern European Regional Programming Contest (NWERC 2016)
    NAIPC-2016
    BZOJ2498 : Xavier is Learning to Count
    ACM ICPC Vietnam National Second Round
    XVI Open Cup named after E.V. Pankratiev. GP of Ukraine
    XVI Open Cup named after E.V. Pankratiev. GP of Peterhof
    HDU5509 : Pattern String
    BZOJ4583 : 购物
  • 原文地址:https://www.cnblogs.com/hellojesson/p/10635047.html
Copyright © 2011-2022 走看看