工作需要,前段时间写的nginx一键安装脚本,废话不多说,上脚本...
CentOS(32位)(RedHat上安装需要将yum仓库地址更改):
- [root@localhost ~]# uname -r
- 2.6.18-308.el5
将系统安装盘放入光驱内
chmod +x nginx.sh 执行下面的脚本
- #!/bin/sh
- # 2013 install scripts
- # Author:lc
- #base
- NOW_DIR=$(pwd)
- DOWN_DIR=$NOW_DIR/down
- IN_DIR="/usr/local"
- #soft url and down
- NGINX_DU="http://nginx.org/download/nginx-1.2.6.tar.gz"
- PCRE_DU="http://jaist.dl.sourceforge.net/project/pcre/pcre/8.32/pcre-8.32.tar.gz"
- #soft version
- NGINX_VERSION="nginx-1.2.6"
- PCRE_VERSION="pcre-8.32"
- #yum安装依赖库
- mount /dev/cdrom /mnt
- if [ ! -d /mnt/CentOS ];then
- exit
- else
- rm -f /etc/yum.repos.d/*
- touch /etc/yum.repos.d/local.repo
- cat > /etc/yum.repos.d/local.repo << EOF
- [base]
- name=base
- baseurl=file:///mnt/
- gpgcheck=0
- enabled=1
- EOF
- yum clean all
- yum -y install gcc gcc-c++ gcc-g77 openssl-devel libtool readline-devel libxml2 libxml2-devel libtool autoconf automake gd libjpeg libjpeg-devel libpng libpng-devel libmcrypt* libtool-ltdl-devel* freetype freetype-devel fiex* zlib zlib-devel glibc glibc-devel glib2 glib2-devel openldap openldap-devel nss_ldap ncurses-devel openldap-clients openldap-servers
- [ $? != 0 ] && err_exit "yum install err"
- fi
- if [ -d $DOWN_DIR ];then
- cd $DOWN_DIR
- else
- mkdir $DOWN_DIR
- cd $DOWN_DIR
- fi
- #pcre
- function pcre_ins() {
- echo "installing pcre..."
- if [ -e $PCRE_VERSION.tar.gz ];then
- tar zxvf $PCRE_VERSION.tar.gz
- cd $PCRE_VERSION
- else
- wget -c $PCRE_DU
- tar zxvf $PCRE_VERSION.tar.gz
- cd $PCRE_VERSION
- fi
- ./configure
- [ $? != 0 ] && err_exit "pcre configure err"
- make
- [ $? != 0 ] && err_exit "pcre make err"
- make install
- [ $? != 0 ] && err_exit "pcre make install err"
- }
- #nginx
- function nginx_ins() {
- echo "installing nginx..."
- cd $DOWN_DIR
- if [ -e $NGINX_VERSION.tar.gz ];then
- tar zxvf $NGINX_VERSION.tar.gz
- cd $NGINX_VERSION
- else
- wget -c $NGINX_DU
- tar zxvf $NGINX_VERSION.tar.gz
- cd $NGINX_VERSION
- fi
- ./configure --prefix=$IN_DIR/nginx --with-http_stub_status_module --with-http_gzip_static_module
- [ $? != 0 ] && err_exit "nginx configure err"
- make
- [ $? != 0 ] && err_exit "nginx make err"
- make install
- [ $? != 0 ] && err_exit "nginx make install err"
- cd /lib
- ln -s libpcre.so.0.0.1 libpcre.so.1
- $IN_DIR/nginx/sbin/nginx
- #kill -QUIT `cat $IN_DIR/nginx/nginx.pid`
- #kill -HUP `cat $IN_DIR/nginx/nginx.pid`
- }
- #err_exit
- function err_exit() {
- echo
- echo
- echo "----Install Error: $1 -----------"
- echo
- echo
- exit
- }
- pcre_ins
- nginx_ins
转载于:https://blog.51cto.com/lycan/1167849