• 手动安装Nginx


    本分类下有一个环境一键安装.那这背后发生了什么呢?咱们手动使用源码进行安装.
    1.首先保证有一个能联网的centos.
    2.百度 ningx 官网   点download  http://nginx.org/en/download.html  找到最新版的nginx下载地址. 发贴时最新的是1.12 http://nginx.org/download/nginx-1.12.0.tar.gz
    3.进行centos  执行命令   

    [Shell] 纯文本查看 复制代码
    1
    2
    3
    4
    #安装wget
    yum install wget -y
    #安装gcc和c++编译器
    yum install gcc gcc-c++ -y


    4.新建临时目录  /temp  然后下载并解压. 命令如下

    [Shell] 纯文本查看 复制代码
    1
    2
    3
    4
    5
    mkdir /temp;
    cd /temp;
    wget http://nginx.org/download/nginx-1.12.0.tar.gz
    tar zxvf ./nginx-1.12.0.tar.gz
    cd /temp/nginx-1.12.0


    得到目录 

    [root@localhost nginx-1.12.0]# pwd
    /temp/nginx-1.12.0
    [root@localhost nginx-1.12.0]# ll
    total 724
    drwxr-xr-x. 6 1001 1001   4096 Apr 17 11:42 auto
    -rw-r--r--. 1 1001 1001 277049 Apr 12 22:46 CHANGES
    -rw-r--r--. 1 1001 1001 421985 Apr 12 22:46 CHANGES.ru
    drwxr-xr-x. 2 1001 1001   4096 Apr 17 11:42 conf
    -rwxr-xr-x. 1 1001 1001   2481 Apr 12 22:46 configure
    drwxr-xr-x. 4 1001 1001   4096 Apr 17 11:42 contrib
    drwxr-xr-x. 2 1001 1001   4096 Apr 17 11:42 html
    -rw-r--r--. 1 1001 1001   1397 Apr 12 22:46 LICENSE
    drwxr-xr-x. 2 1001 1001   4096 Apr 17 11:42 man
    -rw-r--r--. 1 1001 1001     49 Apr 12 22:46 README
    drwxr-xr-x. 9 1001 1001   4096 Apr 17 11:42 src


    5.linux三大安装步骤   配置,编译,安装  第一步,配置
    --prefix=/安装后的路径  注意这基本是所有安装程序的通用的配置属性
    输入命令

    [Shell] 纯文本查看 复制代码
    1
    ./configure --prefix=/usr/local/nginx-mytest



    接下来会报错 如下

    ./configure: error: the HTTP rewrite module requires the PCRE library.
    You can either disable the module by using --without-http_rewrite_module
    option, or install the PCRE library into the system, or build the PCRE library
    statically from the source with nginx by using --with-pcre=<path> option.


    咱们需要安装一个这样的环境对能继续 . 根据上面的意思.咱们先安装 pcre 再指定路径 指定方法在上面就是 --with-pcre=<path>
    6.安装pcre.百度这个词得到官网. 然后找到下载路径如下
    ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/  这里面有一些列表.咱们找到最新的即可 . 目前是 
    ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz下载,解压,编译

    [Shell] 纯文本查看 复制代码
    1
    2
    3
    4
    mkdir /temp;
    cd /temp;
    wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
    tar zxvf pcre-8.39.tar.gz

    到此得到了pcre的源码路径 为/temp/pcre-8.39
    7.上一步得到安装路径/usr/local/pcre-8.39  接下来咱们从新编译 nginx 注意别忘记  --with-pcre=<path>

    [Shell] 纯文本查看 复制代码
    1
    2
    cd /temp/nginx-1.12.0
    ./configure --prefix=/usr/local/nginx-mytest   --with-pcre=/temp/pcre-8.39



    发现完成
    第二个命令就是 make   也就是编译, 一般可以跟第三步一起执行,第三步是make install  .所以我们得到命令

    [Shell] 纯文本查看 复制代码
    1
    make && make install



    接下来去/usr/local/nginx-mytest看看吧.安装成功了

  • 相关阅读:
    [php-src]一个Php扩展的结构
    告别2015,迎来2016
    [JS]应用splice删除多元素时出现的坑
    [Ng]Angular应用点概览
    [MongoDB]Mongodb攻略
    GNU M4
    [Linux]服务管理:RPM包, 源码包
    [Shell]条件判断与流程控制:if, case, for, while, until
    [Shell]字符截取命令:cut, printf, awk, sed
    [Shell]正则表达式与通配符
  • 原文地址:https://www.cnblogs.com/hangxing1996/p/6722302.html
Copyright © 2020-2023  润新知