1. 程式人生 > >Linux安裝nginx(shell指令碼)&軟體安裝之nginx

Linux安裝nginx(shell指令碼)&軟體安裝之nginx

1.編寫installNginx.sh檔案

#!/bin/bash

mydir=`pwd`

if [ ! -f "$mydir/nginx-1.10.2.tar.gz" ];then
        wget http://nginx.org/download/nginx-1.10.2.tar.gz
fi
if [ ! -f "$mydir/openssl-fips-2.0.10.tar.gz" ];then
        wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
fi
if [ ! -f "$mydir/zlib-1.2.11.tar.gz" ];then
        wget http://zlib.net/zlib-1.2.11.tar.gz
fi
if [ ! -f "$mydir/pcre-8.40.tar.gz" ];then
        wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
fi

cd /etc/yum.repo.d/
rm -rf *.repo

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

cd $mydir

yum -y install gcc-c++

rm -rf openssl-fips-2.0.10
rm -rf pcre-8.40
rm -rf zlib-1.2.11
rm -rf nginx-1.10.2

tar zxvf openssl-fips-2.0.10.tar.gz
cd openssl-fips-2.0.10
./config && make && make install

cd ..

tar zxvf pcre-8.40.tar.gz
cd pcre-8.40
./configure && make && make install

cd ..

tar zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure && make && make install

cd ..

tar zxvf nginx-1.10.2.tar.gz
cd nginx-1.10.2
./configure && make && make install

cd ..

ln -s /usr/local/lib/libpcre.so.1 /lib64

/usr/local/nginx/sbin/nginx

2.修改installNginx.sh檔案執行屬性

chmod +x  installNginx.sh

3.執行installNginx.sh指令碼