nginx 腳本安裝

#!/bin/bash
set -x
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH


# Check if user is root
if [ $(id -u) != "0" ]; then
    echo "Error: You must be root to run this script, please use root to install this shell script"
    exit 1
fi


yum -y install gcc wget gcc-c++ automake autoconf libtool libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed pcre pcre-devel openssl openssl-devel zlib zlib-devel


groupadd -r nginx
useradd -r -g nginx  nginx


#install pcre
cd /usr/local/src/
wget https://ftp.pcre.org/pub/pcre/pcre-8.21.tar.gz
tar zxvf pcre-8.21.tar.gz
cd pcre-8.21/
./configure
make && make install
cd ../


#install zlib 
wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz 
cd zlib-1.2.11
./configure
make
make install
cd ../


#install ssl
#wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
#tar -zxvf openssl-1.0.1c.tar.gz
#cd openssl-1.0.1c
#./config
#make
#make install
#cd ../
#--with-openssl=/usr/local/src/openssl-1.0.1c \


#install nginx_cache
wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
tar xf  ngx_cache_purge-2.3.tar.gz 


#install nginx
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2/
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-pcre=/usr/local/src/pcre-8.21 \
--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-ipv6 \
--with-http_v2_module \
--with-threads \
--with-stream \
--with-stream_ssl_module \
--add-module=../ngx_cache_purge-2.3
make && make install


cd ../


cp nginx /etc/init.d/nginx
chmod +x /etc/init.d/nginx


chkconfig --add nginx
chkconfig  nginx on


/etc/init.d/nginx start


ps aux |grep nginx

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章