因为很长时间以来,一直使用docker,所以很久没有在服务器下直接安装过nginx,但这次因为https的事情,需要直接在系统中安装nginx,找来最新版的nginx1.23.3。并且需要支持https,我这里使用的是服务器Ubuntu18.06,安装记录如下:本文地址:http://www.04007.cn/article/1186.html,未经许可,不得转载.
Nginx模块依赖性在安装之前需要先装一些支持模块,先进行一些初始化模块安装如下:本文地址:http://www.04007.cn/article/1186.html,未经许可,不得转载.
1.gzip 模块需要 zlib 库.zlib库用于对HTTP包的内容做gzip格式的压缩,如果我们在nginx.conf中配置了gzip on,并指定对于某些类型(content-type)的HTTP响应使用gzip来进行压缩以减少网络传输量,则在编译时就必须把zlib编译进Nginx。2.rewrite 模块需要 pcre 库.PCRE库支持正则表达式。如果我们在配置文件nginx.conf中使用了正则表达式,那么在编译Nginx时就必须把PCRE库编译进Nginx,因为Nginx的HTTP模块需要靠它来解析正则表达式。
3.ssl 功能需要 openssl 库.如果服务器不只是要支持HTTP,还需要在更安全的SSL协议上传输HTTP,那么需要拥有OpenSSL。本文地址:http://www.04007.cn/article/1186.html,未经许可,不得转载.
apt-get -y install make gcc openssl libssl-dev build-essential unzip apt-get -y install libpcre3 libpcre3-dev libpcrecpp0v5 zlib1g-dev wget http://nginx.org/download/nginx-1.23.3.tar.gz mkdir /opt/nginx_system/ ./configure --user=www --group=www --prefix=/opt/nginx_system/ --with-http_stub_status_module --with-http_ssl_module --with-http_perl_module --with-debug在make的时候遇到报错:本文地址:http://www.04007.cn/article/1186.html,未经许可,不得转载.
/usr/bin/ld: cannot find -lperl collect2: error: ld returned 1 exit status objs/Makefile:242: recipe for target 'objs/nginx' failed make[1]: *** [objs/nginx] Error 1 make[1]: Leaving directory '/opt/downloads/nginx-1.23.3' Makefile:10: recipe for target 'build' failed make: *** [build] Error 2因为在configure的时候指定了要安装--with-http_perl_module模块,解决方法:
wget https://www.cpan.org/src/5.0/perl-5.28.2.tar.gz
tar -xzf perl-5.28.2.tar.gz
cd perl-5.28.2
./Configure -des
make; make install本文地址:http://www.04007.cn/article/1186.html,未经许可,不得转载.
本文地址:http://www.04007.cn/article/1186.html 未经许可,不得转载. 手机访问本页请扫描右下方二维码.
![]() |
![]() |
手机扫码直接打开本页面 |