#!/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
finginx
commandGit=`which "git"`
if [ ! $commandGit ]
then
apt-get install git
fi
makeCommand=`which "make"`
if [ ! $makeCommand ]
then
apt-get install make
figit
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 ../github
git clone https://github.com/openresty/lua-nginx-module.git
git clone https://github.com/simplresty/ngx_devel_kit.gitbash
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.0ui
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 installlua
ng=`/usr/local/luaNginx/sbin/nginx`
if [ $ng ]
then
echo '啓動成功';
exit 1
firest
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/nginxip