1. 程式人生 > >nginx重編譯增加模塊

nginx重編譯增加模塊

nginx nginx重新編譯 nginx源碼包

cd ~/root/nginx

先下載模塊源碼包:

wget -O jemalloc-5.0.1.tar.bz2 http://125.88.182.172:5880/src/jemalloc-5.0.1.tar.bz2

wget -O pcre-$pcre_version.tar.gz http://125.88.182.172:5880/src/pcre-$pcre_version.tar.gz -T 5

wget -O /root/nginx/nginx-$nginxVersion.tar.gz http://125.88.182.172:5880/src/nginx-$nginxVersion.tar.gz -T20

wget -O openssl.tar.gz http://125.88.182.172:5880/src/openssl-1.0.2l.tar.gz -T 5

wget -O ngx_cache_purge.tar.gz http://125.88.182.172:5880/src/ngx_cache_purge-2.3.tar.gz

wget -O /root/nginx/conf/nginx.conf http://125.88.182.172:5880/conf/nginx.conf -T20

wget -O /root/nginx/html/index.html http://125.88.182.172:5880/error/index.html -T 5

wget -O nginx.init http://125.88.182.172:5880/init/nginx.init -T 5

wget -O waf.zip http://125.88.182.172:5880/install/waf/waf.zip

wget -c -O lua-5.3.4.tar.gz http://125.88.182.172:5880/install/src/lua-5.3.4.tar.gz -T 5

wget -c -O LuaJIT-2.0.4.tar.gz http://125.88.182.172:5880/install/src/LuaJIT-2.0.4.tar.gz -T 5

wget -c -O lua-nginx-module-master.zip http://125.88.182.172:5880/install/src/lua-nginx-module-master.zip -T 5

wget -c -O ngx_devel_kit-master.zip http://125.88.182.172:5880/install/src/ngx_devel_kit-master.zip -T 5

wget -c -O lua-nginx-module-master.zip http://125.88.182.172:5880/install/src/lua-nginx-module-master.zip -T 5

wget -c -O ngx_devel_kit-master.zip http://125.88.182.172:5880/install/src/ngx_devel_kit-master.zip -T 5

解壓,需要編譯的就編譯,不需要的就不編譯

tar -xvf jemalloc-5.0.1.tar.bz2

cd jemalloc-5.0.1

./configure

make && make install

ldconfig

cd ..

tar xzf pcre-8.40.tar.gz

yum install libtermcap-devel ncurses-devel libevent-devel readline-devel -y

tar xvf lua-5.3.4.tar.gz

cd lua-5.3.4

make linux

make install

cd ..

tar xvf LuaJIT-2.0.4.tar.gz

cd LuaJIT-2.0.4

make linux

make install

cd ..

export LUAJIT_LIB=/usr/local/lib

export LUAJIT_INC=/usr/local/include/luajit-2.0/

ln -sf /usr/local/lib/libluajit-5.1.so.2 /usr/local/lib64/libluajit-5.1.so.2

echo "/usr/local/lib" >> /etc/ld.so.conf

ldconfig  #

下面接著編譯nginx

cd  nginx-1.12.2

./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path=/var/nginx/proxy_temp_dir --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --add-module=/root/lnmp/ngx_devel_kit-master --add-module=/root/lnmp/lua-nginx-module-master --with-openssl=/root/lnmp/openssl-1.0.2l --with-http_v2_module --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre=/root/lnmp/pcre-8.40 --with-http_realip_module --add-module=/root/lnmp/ngx_cache_purge-2.3 --with-http_gunzip_module --with-stream --with-stream_ssl_module --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_mp4_module --with-ld-opt="-Wl,-E" --with-ld-opt="-ljemalloc"

只是增加模塊:

make

[root@lnmp nginx-1.12.2]# cp -ar objs/nginx /usr/sbin/nginx

cp: overwrite ‘/usr/sbin/nginx’? y

cp: cannot create regular file ‘/usr/sbin/nginx’: Text file busy

[root@lnmp nginx-1.12.2]# cp /usr/sbin/nginx /usr/sbin/nginxbak

[root@lnmp nginx-1.12.2]# service nginx stop

Stopping nginx (via systemctl): [ OK ]

[root@lnmp nginx-1.12.2]# cp -ar objs/nginx /usr/sbin/nginx

cp: overwrite ‘/usr/sbin/nginx’? y

[root@lnmp nginx-1.12.2]# service nginx start

Starting nginx (via systemctl): [ OK ]
如果全新安裝:

make && make install

使用裏面的配置文件去替換默認配置文件即可。

nginx重編譯增加模塊