返回列表 发帖

Nginx/1.14.2重新编译安装使用Jemalloc

笺注:这是在 CentOS8_lnmp1.7_更改Nginx的版本 的基础上进行的。


查看Nginx的版本:
[root@centos8 ~]# nginx -v
nginx version: nginx/1.14.2


查看Nginx的编译参数:
[root@centos8 ~]# nginx -V
nginx version: nginx/1.14.2
built by gcc 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)
built with OpenSSL 1.1.1g  21 Apr 2020
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-openssl=/root/lnmp1.7-full/src/openssl-1.1.1g --with-openssl-opt='enable-weak-ssl-ciphers'





安装Jemalloc:
dnf -y install bzip2 gcc-c++ make lsof

tar -jxvf jemalloc-5.2.1.tar.bz2
cd jemalloc-5.2.1
./configure
make && make install

ldconfig
ln -sf /usr/local/lib/libjemalloc* /usr/lib/





重新编译安装Nginx:(编译的时候使用Jemalloc)
tar -zxvf nginx-1.14.2.tar.gz
cd nginx-1.14.2

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-openssl=/root/lnmp1.7-full/src/openssl-1.1.1g --with-openssl-opt='enable-weak-ssl-ciphers' --with-ld-opt='-ljemalloc' && make && make install

备注:不用备份Nginx的配置文件。


重启Nginx:
[root@centos8 ~]# systemctl restart nginx



再次查看Nginx的编译参数:
[root@centos8 ~]# nginx -V
nginx version: nginx/1.14.2
built by gcc 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)
built with OpenSSL 1.1.1g  21 Apr 2020
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-stream --with-stream_ssl_module --with-openssl=/root/lnmp1.7-full/src/openssl-1.1.1g --with-openssl-opt=enable-weak-ssl-ciphers --with-ld-opt=-ljemalloc


查看Nginx的进程:
[root@centos8 ~]# ps -ef |grep nginx |grep -v grep
root       29331       1  0 21:07 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
www        29332   29331  0 21:07 ?        00:00:00 nginx: worker process


验证Nginx是否使用了Jemalloc:
[root@centos8 ~]# lsof -n |grep jemalloc
nginx     29331                   root  mem       REG              253,0   6123808  201836129 /usr/local/lib/libjemalloc.so.2
nginx     29332                    www  mem       REG              253,0   6123808  201836129 /usr/local/lib/libjemalloc.so.2





笺注:
实验中,Nginx/1.14.2安装云锁的Web应用Nginx的插件后,会重新编译安装Nginx的,但不会改变Nginx的配置文件。

Nginx/1.14.2安装云锁的Web应用Nginx的插件后,Nginx的编译参数:
[root@centos8 ~]# nginx -V
nginx version: nginx/1.14.2
built by gcc 3.4.6 20060404 (Red Hat 3.4.6-3)
built with OpenSSL 1.0.2i  22 Sep 2016
TLS SNI support enabled
configure arguments: --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-stream_ssl_preread_module --with-threads --user=www --group=www





相关文章:
Nginx/1.14.2编译安装使用Jemalloc
CentOS8_云锁+Nginx

返回列表