zoukankan      html  css  js  c++  java
  • 手动安装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看看吧.安装成功了

  • 相关阅读:
    如果让你手写个栈和队列,你还会写吗?【华为云技术分享】
    挑战10个最难的Java面试题(附答案)【上】【华为云技术分享】
    k 近邻算法解决字体反爬手段|效果非常好
    实战!轻松搭建图像分类 AI 服务
    100 个网络基础知识普及,看完成半个网络高手【华为云技术分享】
    周杰伦新歌《说好不哭》上线,程序员哭了......【华为云技术分享】
    云图说|华为云数据库在线迁移大揭秘
    #化鲲为鹏,我有话说# 鲲鹏弹性云服务器配置 Tomcat
    地面光伏电站项目前期申报审批流程及开发建设流程一览!
    HTTP 1.0 Status Code Definitions
  • 原文地址:https://www.cnblogs.com/hangxing1996/p/6722302.html
Copyright © 2011-2022 走看看