Author Topic: compile nginx1.19.5 with Lua on Centos7.x 64bit  (Read 2077 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
compile nginx1.19.5 with Lua on Centos7.x 64bit
« on: ธันวาคม 01, 2020, 11:06:37 PM »
=== compile nginx1.19.5 with Lua on Centos7.x 64bit
yum install nginx-1.19.5

เราสามารถทำการ install ผ่าน repo nginx ของ nginx ได้ครับผม จะทำให้ง่ายกว่า แล้วค่อยมารัน compile module lua เพิ่มได้ครับผม

wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
wget https://github.com/chaoslawful/lua-nginx-module/archive/v0.10.10.zip
wget http://nginx.org/download/nginx-1.19.5.tar.gz
wget https://nchc.dl.sourceforge.net/project/pcre/pcre/8.41/pcre-8.41.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz

yum install gcc zlib-devel gcc-c++
yum install openssl-devel-1.0.2k openssl11-libs

cd /home/packetlove
tar zxvf v0.3.0.tar.gz
unzip -q v0.10.10.zip

tar zxf LuaJIT-2.0.5.tar.gz
cd LuaJIT-2.0.5
make && make install

tar zxf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install

tar zxf nginx-1.19.5.tar.gz
cd nginx-1.19.5
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.0

tar zxf nginx-1.19.5.tar.gz
cd nginx-1.19.5
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.0

==ทำการ reconfigure module nginx ที่สำคัญคือเพิ่ม module lua เข้าไปครับ
== --add-module=../ngx_devel_kit-0.3.0/ --add-module=../lua-nginx-module-0.10.10/
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'  --add-module=../ngx_devel_kit-0.3.0/ --add-module=../lua-nginx-module-0.10.10/
==make
make -j2 && make install
==link
ln -s /usr/local/lib/libluajit-5.1.so.2 /lib64/libluajit-5.1.so.2

systemctl restart nginx
netstat -ntlp
เรียบร้อยครับผม
nginx -V ก็จะมี lua-nginx-module ขึ้นมาด้วยครับผม : )