Linux 编译安装 Nginx
Nginx Linux OpenSSL About 2,341 words下载解压
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=<path> 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=<path> 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
官网
Views: 5,196 · Posted: 2019-04-19
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...