Nginx 자동 설치 스 크 립 트 (비교적 간단 하고 최적화 해 야 함)

Nginx 설치 스 크 립 트: pcre, Nginx 를 자동 으로 설치 하고 사용 자 를 만 듭 니 다. 설치 완료 후 필요 한 테스트 를 진행 합 니 다.그러나 관련 판단 이 없 기 때문에 후속 적 인 최적화 가 필요 하 다.
#!/bin/sh
################################################
# This scripts is created by miaocbin
# QQ:289303323
# blog:http://miaocbin.blog.51cto.com
################################################
# deploy online
#

# set the variable
NGINX_TOOL_DIR=/home/$username/tools
NGINX_VERSION=1.6.3
NGINX_INSTALL_DIR=/usr/local/nginx-$NGINX_VERSION
NGINX_LN_DIR=/usr/local/nginx

# create the dir for the software storage.
mkdir -p $NGINX_TOOL_DIR
cd $NGINX_TOOL_DIR

echo "----- step 1. install pcre -----"
[ ! -f pcre-8.36.tar.gz ] && \
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
tar xzf pcre-8.36.tar.gz
cd pcre-8.36
./configure
make && make install
cd ../

echo "----- step 2. add NGINX user -----"
useradd nginx -s /sbin/nologin -M 
sleep 1

echo "----- step 3. download or upload NGINX software -----"
[ ! -f nginx-${NGINX_VERSION}.tar.gz ] && \
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar xzf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}
./configure --prefix=${NGINX_INSTALL_DIR} --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module
make && make install
ln -s ${NGINX_INSTALL_DIR}  ${NGINX_LN_DIR}

echo "----- step 4. run NGINX service -----"
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig

${NGINX_LN_DIR}/sbin/nginx -t
${NGINX_LN_DIR}/sbin/nginx

echo "----- step 5. check NGINX service -----"
ps -ef |grep nginx 
echo ----------
lsof -i tcp:80
echo ----------
curl 127.0.0.1
echo "nginx is installed."

좋은 웹페이지 즐겨찾기