Last active
April 3, 2020 15:34
-
-
Save karminski/135e58d2f52b91625dfc to your computer and use it in GitHub Desktop.
nginx with lua-nginx-module auto deploy scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# deploy_nginx_with_lua_nginx_module.sh | |
# @version 171026:7 | |
# @author karminski <[email protected]> | |
# | |
# @changes | |
# 171026:7 CHANGE to nginx-1.10.3, lua-nginx-module-v0.10.10, luajit2-v2.1-20170925 | |
# 170825:6 REMOVE --with-debug compile option to solve peformance issue. | |
# 170627:5 CHANGE to nginx-1.10.3, lua-nginx-module-v0.10.8 | |
# 161226:4 CHANGE to nginx-1.10.2, lua-nginx-module-v0.10.8, luajit2-v2.1-20161104 | |
# 160816:3 CHANGE to nginx-1.10.1, lua-nginx-module-v0.10.8, luajit2-v2.1-20160517 | |
# ... | |
# @source | |
# https://gist.github.com/karminski/135e58d2f52b91625dfc | |
# [manual config area] | |
SOURCE_LUAJIT=https://github.com/openresty/luajit2/archive/v2.1-20170925.tar.gz | |
SOURCE_NGINX=http://nginx.org/download/nginx-1.10.3.tar.gz | |
SOURCE_NGX_DEVEL_KIT=https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz | |
SOURCE_LUA_NGINX_MODULE=https://github.com/openresty/lua-nginx-module/archive/v0.10.10.tar.gz | |
LUAJIT_INSTALLER_PATH=/data/apps/luajit | |
LUAJIT_INSTALL_PATH=/data/apps/luajit | |
NGINX_INSTALLER_PATH=/data/apps/src/nginx_installer | |
NGINX_INSTALL_PATH=/data/apps/nginx | |
UNTAR_FOLDER_LUAJIT=luajit2-2.1-20170925 | |
UNTAR_FOLDER_NGINX=nginx-1.10.3 | |
UNTAR_FOLDER_NGX_DEVEL_KIT=ngx_devel_kit-0.3.0 | |
UNTAR_FOLDER_LUA_NGINX_MODULE=lua-nginx-module-0.10.10 | |
# [dump config for check] | |
echo -e "\033[34m- nginx_deploy_with_lua_nginx_module.sh start \033[0m" | |
echo -e "\033[34m--------------------------------------------- \033[0m" | |
echo -e "\033[34m- SOURCE_LUAJIT: ${SOURCE_LUAJIT} \033[0m" | |
echo -e "\033[34m- SOURCE_NGINX: ${SOURCE_NGINX} \033[0m" | |
echo -e "\033[34m- SOURCE_NGX_DEVEL_KIT: ${SOURCE_NGX_DEVEL_KIT} \033[0m" | |
echo -e "\033[34m- SOURCE_LUA_NGINX_MODULE: ${SOURCE_LUA_NGINX_MODULE} \033[0m" | |
echo -e "\033[34m- LUAJIT_INSTALLER_PATH: ${LUAJIT_INSTALLER_PATH} \033[0m" | |
echo -e "\033[34m- LUAJIT_INSTALL_PATH: ${LUAJIT_INSTALL_PATH} \033[0m" | |
echo -e "\033[34m- NGINX_INSTALLER_PATH: ${NGINX_INSTALLER_PATH} \033[0m" | |
echo -e "\033[34m- NGINX_INSTALL_PATH: ${NGINX_INSTALL_PATH} \033[0m" | |
echo -e "\033[34m- UNTAR_FOLDER_LUAJIT: ${UNTAR_FOLDER_LUAJIT} \033[0m" | |
echo -e "\033[34m- UNTAR_FOLDER_NGINX: ${UNTAR_FOLDER_NGINX} \033[0m" | |
echo -e "\033[34m- UNTAR_FOLDER_NGX_DEVEL_KIT: ${UNTAR_FOLDER_NGX_DEVEL_KIT} \033[0m" | |
echo -e "\033[34m- UNTAR_FOLDER_LUA_NGINX_MODULE: ${UNTAR_FOLDER_LUA_NGINX_MODULE} \033[0m" | |
# [install dependency] | |
yum install -y pcre-devel.x86_64 openssl-devel.x86_64 wget gcc g++ | |
# [fetch and install luajit] | |
## [fetch luajit source] | |
mkdir -p ${LUAJIT_INSTALLER_PATH} | |
cd ${LUAJIT_INSTALLER_PATH} | |
wget ${SOURCE_LUAJIT} | |
for i in `ls *.tar.gz` | |
do | |
tar -zxvf $i | |
done | |
cd ${UNTAR_FOLDER_LUAJIT} | |
REPLACED_PATH=`echo ${LUAJIT_INSTALL_PATH} | awk '{gsub("/", "\\\/", $0); printf("%s\n", $0);}'` | |
sed -i "s/export PREFIX= \/usr\/local/export PREFIX= ${REPLACED_PATH}/g" Makefile | |
echo -e "\033[34m- [FETCH FINISH]\033[0m" | |
## [make and install luajit] | |
# if you want debug with luajit, use: make CCDEBUG=-g | |
make -j | |
make install | |
echo -e "\033[34m- luajit info: \033[0m" | |
${LUAJIT_INSTALL_PATH}/bin/luajit -v | |
echo -e "\033[34m- [luajit INSTALL FINISH]\033[0m" | |
# [fetch and install nginx] | |
## [fetch installer source] | |
mkdir -p ${NGINX_INSTALLER_PATH} | |
cd ${NGINX_INSTALLER_PATH} | |
wget ${SOURCE_NGINX} | |
wget ${SOURCE_NGX_DEVEL_KIT} | |
wget ${SOURCE_LUA_NGINX_MODULE} | |
for i in `ls *.tar.gz` | |
do | |
tar -zxvf $i | |
done | |
echo -e "\033[34m- [FETCH FINISH]\033[0m" | |
## [configure, build and install] | |
cd ${NGINX_INSTALLER_PATH} | |
export LUAJIT_LIB=${LUAJIT_INSTALL_PATH}/lib | |
export LUAJIT_INC=${LUAJIT_INSTALL_PATH}/include/luajit-2.1 | |
echo -e "\033[34m- config LUAJIT_LIB to ${LUAJIT_LIB} \033[0m" | |
echo -e "\033[34m- config LUAJIT_INC to ${LUAJIT_INC} \033[0m" | |
cd "${NGINX_INSTALLER_PATH}/${UNTAR_FOLDER_NGINX}" | |
chmod +x ./configure | |
./configure --prefix=${NGINX_INSTALL_PATH} \ | |
--with-ld-opt="-Wl,-rpath,${LUAJIT_LIB}" \ | |
--with-stream \ | |
--with-stream_ssl_module \ | |
--with-http_ssl_module \ | |
--with-http_gunzip_module \ | |
--with-http_gzip_static_module \ | |
--with-http_stub_status_module \ | |
--add-module=${NGINX_INSTALLER_PATH}/${UNTAR_FOLDER_NGX_DEVEL_KIT} \ | |
--add-module=${NGINX_INSTALLER_PATH}/${UNTAR_FOLDER_LUA_NGINX_MODULE} \ | |
make -j && make install | |
export PATH=$PATH:${NGINX_INSTALL_PATH}/sbin | |
## [run nginx -v] | |
echo -e "\033[34m- nginx info: \033[0m" | |
${NGINX_INSTALL_PATH}/sbin/nginx -V | |
echo -e "\033[34m- [nginx INSTALL FINISH]\033[0m" | |
echo -e "\033[34m- [ALL DONE]\033[0m" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment