前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >源码编译安装nginx

源码编译安装nginx

作者头像
程裕强
发布2022-05-06 17:15:15
4470
发布2022-05-06 17:15:15
举报

源码编译安装基本步骤:

1、下载 2、解压源码包 3、准备编译环境 4、检查(依赖,兼容),预编译 5、编译 6、安装

所以nginx的源码编译安装也是基本的6步:

1、下载源码

     http://nginx.org/,单击download,下载最新的stable的源码

2、解压源码包

    [root@master ~]# tar -zxvf nginx-1.10.2.tar.gz

3、准备编译环境

   [root@master ~]# yum grouplist | grep Development    Additional Development    Desktop Platform Development    Development tools    Server Platform Development

  [root@master ~]# yum groupinstall -y Development Tools

4、检查(依赖,兼容),预编译

   [root@master nginx-1.10.2]# ls    auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src

4.1  查看帮助

  [root@master nginx-1.10.2]# ./configure --help     --help                                        print this message     --prefix=PATH                          set installation prefix     --sbin-path=PATH                   set nginx binary pathname

    ...................

4.2  预编译,设置安装路径

  [root@master nginx-1.10.2]# ./configure --prefix=/opt/nginx-1.10.2

  ...........

  checking for PCRE library in /usr/pkg/ ... not found   checking for PCRE library in /opt/local/ ... not found ./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.

4.3 安装依赖

  [root@master nginx-1.10.2]# yum search pcre   Loaded plugins: fastestmirror

  pcre-devel.i686 : Development files for pcre   pcre-devel.x86_64 : Development files for pcre   pcre-static.x86_64 : Static library for pcre   pcre.i686 : Perl-compatible regular expression library   pcre.x86_64 : Perl-compatible regular expression library

  [root@master nginx-1.10.2]# yum install -y pcre-devel

4.4 再次预编译,安装依赖  

  [root@master nginx-1.10.2]# ./configure --prefix=/opt/nginx-1.10.2

./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.

  [root@master nginx-1.10.2]# yum search zlib

  jzlib.x86_64 : JZlib re-implementation of zlib in pure Java   jzlib-demo.x86_64 : Examples for jzlib   jzlib-javadoc.x86_64 : Javadoc for jzlib   perl-Compress-Raw-Zlib.x86_64 : Low-Level Interface to the zlib compression library   perl-Compress-Zlib.x86_64 : A module providing Perl interfaces to the zlib compression library   perl-IO-Zlib.x86_64 : Perl IO:: style interface to Compress::Zlib   zlib.i686 : The zlib compression and decompression library   zlib.x86_64 : The zlib compression and decompression library   zlib-devel.i686 : Header files and libraries for Zlib development   zlib-devel.x86_64 : Header files and libraries for Zlib development   zlib-static.x86_64 : Static libraries for Zlib development

  [root@master nginx-1.10.2]# yum install -y zlib-devel

4.5 重复执行预编译,直到没有错误

  [root@master nginx-1.10.2]# ./configure --prefix=/opt/nginx-1.10.2

  nginx path prefix: "/opt/nginx-1.10.2"   nginx binary file: "/opt/nginx-1.10.2/sbin/nginx"   nginx modules path: "/opt/nginx-1.10.2/modules"   nginx configuration prefix: "/opt/nginx-1.10.2/conf"   nginx configuration file: "/opt/nginx-1.10.2/conf/nginx.conf"   nginx pid file: "/opt/nginx-1.10.2/logs/nginx.pid"   nginx error log file: "/opt/nginx-1.10.2/logs/error.log"   nginx http access log file: "/opt/nginx-1.10.2/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"

5、编译

  [root@master nginx-1.10.2]# make

 ................

  make[1]: Leaving directory `/root/nginx-1.10.2'

6、安装

  [root@master nginx-1.10.2]# make install

  make -f objs/Makefile install   .............   make[1]: Leaving directory `/root/nginx-1.10.2'

[root@master nginx-1.10.2]# cd /opt/nginx-1.10.2/   [root@master nginx-1.10.2]# ls   conf  html  logs  sbin

7 、启动服务

[root@master nginx-1.10.2]# ./sbin/nginx

2021-5-10更新

tar -zxvf nginx-1.20.0.tar.gz  cd nginx-1.20.0/  ./configure --prefix=/usr/local/nginx  sudo yum install -y pcre-devel ./configure --prefix=/usr/local/nginx  make sudo make install cd /usr/local/nginx/ sudo  ./sbin/nginx

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-02-06,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档