linux编译 nginx,Linux 编译安装 Nginx

下载解压

wget http://nginx.org/download/nginx-1.16.1.tar.gz

tar -zxvf nginx-1.16.1.tar.gz

cd nginx-1.16.1

查看模块支持

./configure --help

安装配置

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream

缺少 pcre、OpenSSL 依赖

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

./configure: error: SSL modules require the OpenSSL library.

You can either do not enable the modules, or install the OpenSSL library

into the system, or build the OpenSSL library statically from the source

with nginx by using --with-openssl= option.

下载依赖

无需安装。

pcre

wget https://netix.dl.sourceforge.net/project/pcre/pcre/8.43/pcre-8.43.tar.gz

tar -zxvf pcre-8.43.tar.gz

OpenSSL

wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz

tar -zxvf openssl-1.1.0h.tar.gz

编译出错

cd /usr/local/pcre/bin \

&& if [ -f Makefile ]; then make distclean; fi \

&& CC="cc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \

./configure --disable-shared

/bin/sh: line 2: ./configure: No such file or directory

make[1]: *** [/usr/local/pcre/bin/Makefile] Error 127

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

make: *** [build] Error 2

cd /usr/local/openssl/bin/ \

&& if [ -f Makefile ]; then make clean; fi \

&& ./config --prefix=/usr/local/openssl/bin//.openssl no-shared no-threads \

&& make \

&& make install_sw LIBDIR=lib

/bin/sh: line 2: ./config: No such file or directory

make[1]: *** [/usr/local/openssl/bin//.openssl/include/openssl/ssl.h] Error 127

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

make: *** [build] Error 2

指定依赖路径

--with-pcre、--with-openssl指定到依赖的根目录即可,无需指定到bin目录。

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-pcre=/home/root/pcre-8.40/ --with-openssl=/home/root/openssl-1.1.0h/

编译

先不一起执行make install,编译成功后,进入objs/目录下,执行./nginx -t和./nginx -V检查

make

安装

make install

运行

指定了--prefix,安装好后到/usr/local/nginx/sbin下运行即可。

./nginx

官网

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值