ubuntu+nginx+lua自动安装脚本

原创
2018/05/11 15:43
阅读数 454

#!/bin/bash
####初始化时间
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 apt-get update
 #apt-get install -f
rp=/usr/local/src
cd $rp
if [ ! -s "$rp/nginx-1.14.0" ] 
then 
 wget http://nginx.org/download/nginx-1.14.0.tar.gz
 #mkdir nginx
 tar -zxvf ./nginx-1.14.0.tar.gz
fi

commandGit=`which "git"`
if [ ! $commandGit ]
then
  apt-get install git
fi
makeCommand=`which "make"`
if [ ! $makeCommand ]
then
 apt-get install make
fi

gccCommand=`which "gcc"`
if [ !$gccCommand ] 
then
 apt-get install build-essential 
fi
git clone http://luajit.org/git/luajit-2.0.git
cp ./luajit-2.0/Makefile ./luajit-2.0/MakefileBak
sed -i 's/PREFIX= \/usr\/local/PREFIX= \/usr\/local\/luajit/g'  $rp/luajit-2.0/Makefile
cd  ./luajit-2.0
make && make install
cd ../

git clone https://github.com/openresty/lua-nginx-module.git
git clone https://github.com/simplresty/ngx_devel_kit.git

apt-get install libpcre3 libpcre3-dev
apt-get install openssl  libssl-dev
isUser=`id nginx`
#创建运行用户组
if [ ! $isUser ]
then
 useradd nginx -s /sbin/nologin -M
fi
iip=/usr/local
##############
##这两部很重要,否则nginx在编译的时候找不到lua库
##############
export LUAJIT_LIB=$iip/luajit/lib 
export LUAJIT_INC=$iip/luajit/include/luajit-2.0

cd $rp/nginx-1.14.0
#iip=/usr/local
./configure --user=nginx --group=nginx  --prefix=$iip/luaNginx  --with-http_stub_status_module --with-http_ssl_module --add-module=$rp/lua-nginx-module --add-module=$rp/ngx_devel_kit
make && make install

ng=`/usr/local/luaNginx/sbin/nginx`
if [ $ng ]
then
  echo '启动成功';
  exit 1
fi

repalce=`sed -i '$a \/usr/local\/luajit\/lib'  /etc/ld.so.conf.d/libc.conf `
if [ ! $repalce ]
then
 echo  $repalce
  exit 1
fi
###########
#必须切换到该目录下,运行ldconfig才有效果
##########
cd  /etc/ld.so.conf.d/
ldconfig
/usr/local/luaNginx/sbin/nginx

展开阅读全文
加载中

作者的其它热门文章

打赏
0
1 收藏
分享
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部