Linux 编译安装 Nginx
Nginx Linux OpenSSL 大约 2341 字下载解压
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
官网
阅读 2863 · 发布于 2019-04-19
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
Windows 使用 netsh 实现端口转发阅读 17
-
Java @Contended 避免缓存行伪共享阅读 641
-
PhpStorm 设置大括号不换行阅读 5267
-
Prometheus+Grafana+nginx-prometheus-exporter 监控 Nginx阅读 663
-
Windows 下使用 Wireshark 抓取 HTTP2 加密数据包阅读 2383
-
Java 中的 GC Roots阅读 117
-
MySQL 启动停止重启服务阅读 872
-
Nginx upstream timed out 10060阅读 2608
-
Java 判断后缀是否匹配规则阅读 1054
-
Linux 不排序去除重复行和不排序统计重复行阅读 3905