nginx編譯安裝Lua模塊
- nginx:高性能web服務(wù)器
- LuaJIT:即采用C語言寫的Lua代碼的解釋器。
- lua-nginx-module (ngx_lua) :可在 Nginx 中嵌入 Lua 語言。讓 Nginx 可以支持 Lua 強大的語法冕杠。
- NDK(nginx developmentkit):模塊是一個拓展nginx服務(wù)器核心功能的模塊,第三方模塊開發(fā)可以基于它來快速實現(xiàn)撬碟。NDK提供函數(shù)和宏處理一些基本任務(wù)鹃答,減輕第三方模塊開發(fā)的代碼量
開發(fā)者如果要依賴這個模塊做開發(fā),需要將這個模塊一并參與nginx編譯壤短,同時需要在自己的模塊配置中聲明所需要使用的特性。
獲取最新Nginx下載地址-點擊跳轉(zhuǎn)
獲取最新LuaJIT下載地址-點擊跳轉(zhuǎn)
1.獲取Nginx慨仿、LuaJIT久脯、lua-nginx-module、ngx_devel_kit源碼文件
wget http://nginx.org/download/nginx-1.17.5.tar.gz
wget http://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz
wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz
wget https://github.com/openresty/lua-nginx-module/archive/v0.10.13.tar.gz
2.創(chuàng)建放置源碼目錄與nginx目錄
mkdir /opt/makecode
mkdir /etc/nginx
3.解壓源碼文件
tar xvf LuaJIT-2.1.0-beta3.tar.gz -C /opt/
tar xvf nginx-1.17.5.tar.gz -C /opt/
tar xvf v0.10.13.tar.gz -C /opt/
tar xvf v0.3.0.tar.gz -C /opt/
4.切換目錄并對解壓目錄改名
cd /opt
mv nginx-1.17.5/ /opt/nginx
mv LuaJIT-2.1.0-beta3/ /opt/luaJIT
mv lua-nginx-module-0.10.13/ /etc/nginx/lua-nginx-module
mv ngx_devel_kit-0.3.0/ /etc/nginx/ngx_devel_kit
5.編譯安裝luaJIT
cd /opt/luaJIT
make PREFIX=/opt/luajit
make install PREFIX=/opt/luajit
6.定義luaJIT環(huán)境變量并刷新環(huán)境變量文件
echo -e 'export LUAJIT_LIB=/opt/luajit/lib\nexport LUAJIT_INC=/opt/luajit/include/luajit-2.1' > /etc/profile.d/nginx.sh
. /etc/profile.d/nginx.sh
7.安裝nginx編譯時需要的依賴
yum -y install pcre-devel opensslo penssl-devel.x86_64
8.編譯安裝nginx
cd /opt/nginx
./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=/etc/nginx/lua-nginx-module --add-module=/etc/nginx/ngx_devel_kit
make -j2
make install
9.查看編譯狀態(tài)
nginx -V