zoukankan      html  css  js  c++  java
  • nginx源码安装

    访问nginx网站:nginx.org
    stable:稳定版
    注:如果不想查看博主安装过程中遇到的问题,可以翻到最下面查看快速安装nginx的复制粘贴操作
    点开链接后,复制如下图链接地址
     
    解压nginx压缩包:
    tar -xvf nginx-1.14.2.tar.gz
     
    去目录下执行安装脚本
    [root@localhost nginx-1.14.2]# ./configure 
    checking for OS
     + Linux 3.10.0-957.el7.x86_64 x86_64
    checking for C compiler ... not found
    
    ./configure: error: C compiler cc is not found
    发现缺少gcc编译环境,安装gcc
    [root@localhost nginx-1.14.2]# yum list| grep gcc
    gcc.x86_64                                  4.8.5-36.el7               @base    
    libgcc.x86_64                               4.8.5-36.el7               @anaconda
    compat-gcc-44.x86_64                        4.4.7-8.el7                base     
    compat-gcc-44-c++.x86_64                    4.4.7-8.el7                base     
    compat-gcc-44-gfortran.x86_64               4.4.7-8.el7                base     
    gcc-c++.x86_64                              4.8.5-36.el7               base     
    gcc-gfortran.x86_64                         4.8.5-36.el7               base     
    gcc-gnat.x86_64                             4.8.5-36.el7               base     
    gcc-go.x86_64                               4.8.5-36.el7               base     
    gcc-objc.x86_64                             4.8.5-36.el7               base     
    gcc-objc++.x86_64                           4.8.5-36.el7               base     
    gcc-plugin-devel.x86_64                     4.8.5-36.el7               base     
    libgcc.i686                                 4.8.5-36.el7               base     
    relaxngcc.noarch                            1.12-6.el7                 base     
    relaxngcc-javadoc.noarch                    1.12-6.el7                 base     
    [root@localhost nginx-1.14.2]# yum install gcc.x86_64
    再次去执行安装脚本,截取后面的安装信息

    [root@localhost nginx-1.14.2]# ./configure 
    checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
    checking for sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found
    checking for openat(), fstatat() ... found
    checking for getaddrinfo() ... found
    checking for PCRE library ... not found
    checking for PCRE library in /usr/local/ ... not found
    checking for PCRE library in /usr/include/pcre/ ... not found
    checking for PCRE library in /usr/pkg/ ... not found
    checking for PCRE library in /opt/local/ ... not found
    由此可见,缺少pcre库,安装pcre-devel

    [root@localhost nginx-1.14.2]# yum list | grep pcre
    pcre.x86_64                                 8.32-17.el7                @anaconda
    pcre.i686                                   8.32-17.el7                base     
    pcre-devel.i686                             8.32-17.el7                base     
    pcre-devel.x86_64                           8.32-17.el7                base     
    pcre-static.i686                            8.32-17.el7                base     
    pcre-static.x86_64                          8.32-17.el7                base     
    pcre-tools.x86_64                           8.32-17.el7                base     
    pcre2.i686                                  10.23-2.el7                base     
    pcre2.x86_64                                10.23-2.el7                base     
    pcre2-devel.i686                            10.23-2.el7                base     
    pcre2-devel.x86_64                          10.23-2.el7                base     
    pcre2-static.i686                           10.23-2.el7                base     
    pcre2-static.x86_64                         10.23-2.el7                base     
    pcre2-tools.x86_64                          10.23-2.el7                base     
    pcre2-utf16.i686                            10.23-2.el7                base     
    pcre2-utf16.x86_64                          10.23-2.el7                base     
    pcre2-utf32.i686                            10.23-2.el7                base     
    pcre2-utf32.x86_64                          10.23-2.el7                base     
    [root@localhost nginx-1.14.2]# yum install pcre-devel.x86_64 
    再次去执行安装脚本,截取后面的安装信息

    checking for openat(), fstatat() ... found
    checking for getaddrinfo() ... found
    checking for PCRE library ... found
    checking for PCRE JIT support ... found
    checking for zlib library ... not found
    
    ./configure: error: the HTTP gzip module requires the zlib library.
    You can either disable the module by using --without-http_gzip_module
    option, or install the zlib library into the system, or build the zlib library
    statically from the source with nginx by using --with-zlib=<path> option.
    由此可见,这里缺少的zlib-devel

    [root@localhost nginx-1.14.2]# yum list|grep zlib
    zlib.x86_64                                 1.2.7-18.el7               @anaconda
    jzlib.noarch                                1.1.1-6.el7                base     
    jzlib-demo.noarch                           1.1.1-6.el7                base     
    jzlib-javadoc.noarch                        1.1.1-6.el7                base     
    zlib.i686                                   1.2.7-18.el7               base     
    zlib-devel.i686                             1.2.7-18.el7               base     
    zlib-devel.x86_64                           1.2.7-18.el7               base     
    zlib-static.i686                            1.2.7-18.el7               base     
    zlib-static.x86_64                          1.2.7-18.el7               base     
    [root@localhost nginx-1.14.2]# yum install zlib-devel.x86_64 
    ok,这里再次去执行安装脚本去试试,截取最后的安装信息
    checking for openat(), fstatat() ... found
    checking for getaddrinfo() ... found
    checking for PCRE library ... found
    checking for PCRE JIT support ... found
    checking for zlib library ... found
    creating objs/Makefile
    
    Configuration summary
      + using system PCRE library
      + OpenSSL library is not used
      + using system zlib library
    
      nginx path prefix: "/usr/local/nginx"
      nginx binary file: "/usr/local/nginx/sbin/nginx"
      nginx modules path: "/usr/local/nginx/modules"
      nginx configuration prefix: "/usr/local/nginx/conf"
      nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
      nginx pid file: "/usr/local/nginx/logs/nginx.pid"
      nginx error log file: "/usr/local/nginx/logs/error.log"
      nginx http access log file: "/usr/local/nginx/logs/access.log"
      nginx http client request body temporary files: "client_body_temp"
      nginx http proxy temporary files: "proxy_temp"
      nginx http fastcgi temporary files: "fastcgi_temp"
      nginx http uwsgi temporary files: "uwsgi_temp"
      nginx http scgi temporary files: "scgi_temp"
    安装应该是没有问题,不过通过信息查看到openssl库没有使用,这个东西应该是处于nginx安全考虑的吧,也顺手安装好了
    [root@localhost nginx-1.14.2]# yum list|grep openssl
    openssl.x86_64                              1:1.0.2k-16.el7            @anaconda
    openssl-libs.x86_64                         1:1.0.2k-16.el7            @anaconda
    apr-util-openssl.x86_64                     1.5.2-6.el7                base     
    openssl-devel.i686                          1:1.0.2k-16.el7            base     
    openssl-devel.x86_64                        1:1.0.2k-16.el7            base     
    openssl-libs.i686                           1:1.0.2k-16.el7            base     
    openssl-perl.x86_64                         1:1.0.2k-16.el7            base     
    openssl-static.i686                         1:1.0.2k-16.el7            base     
    openssl-static.x86_64                       1:1.0.2k-16.el7            base     
    openssl098e.i686                            0.9.8e-29.el7.centos.3     base     
    openssl098e.x86_64                          0.9.8e-29.el7.centos.3     base     
    xmlsec1-openssl.i686                        1.2.20-7.el7_4             base     
    xmlsec1-openssl.x86_64                      1.2.20-7.el7_4             base     
    xmlsec1-openssl-devel.i686                  1.2.20-7.el7_4             base     
    xmlsec1-openssl-devel.x86_64                1.2.20-7.el7_4   
    [root@localhost nginx-1.14.2]# yum install openssl-devel.x86_64 openssl
    编译安装:

    make && make install
    验证nginx安装是否成功,并启动nginx
    查看在/usr/local/是否存在nginx目录,存在说明安装成功
     
    启动nginx
    /usr/local/nginx/sbin/nginx
    关闭nginx
    /usr/local/nginx/sbin/nginx -s stop
    重启nginx
    /usr/local/nginx/sbin/nginx -s reload
    制作nginx系统启动文件,把权限改成754,然后把文件放到/etc/lib/systemd/system下
    [Unit]  
    Description=nginx
    After=network.target  
       
    [Service]  
    Type=forking  
    ExecStart=/usr/local/nginx/sbin/nginx
    ExecReload=/usr/local/nginx/sbin/nginx -s reload
    ExecStop=/usr/local/nginx/sbin/nginx -s stop
    PrivateTmp=true  
       
    [Install]  
    WantedBy=multi-user.target
     
    总结:
    安装源码包需要安装的依赖,安装完依赖之后运行配置脚本不会报错,可以直接编译安装
    yum install gcc
    yum install pcre-devel
    yum install zlib zlib-devel
    yum install openssl openssl-devel

  • 相关阅读:
    IntelliJ IDEA下自动生成Hibernate映射文件以及实体类
    java 调用本地应用程序 Java打开(.word,.txt,.pdf)文件
    使用GooSeeker爬取数据
    pycharm、idea 2018软件安装教程
    GUI JFrame窗体介绍:
    KindEditor的参考文献
    Python自动化开发学习20-Django的form组件
    Navicat安装教程、建表教程
    import与from...import...的区别
    动态添加,删除和保存
  • 原文地址:https://www.cnblogs.com/huskiesir/p/10242861.html
Copyright © 2011-2022 走看看