Chinaunix首页 | 论坛 | 博客
  • 博客访问: 705978
  • 博文数量: 112
  • 博客积分: 3889
  • 博客等级: 少校
  • 技术积分: 1448
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-19 16:35
个人简介

追求卓越,成功就会在不经意间追上你

文章分类

全部博文(112)

文章存档

2015年(1)

2014年(2)

2013年(1)

2012年(16)

2011年(86)

2010年(6)

分类: LINUX

2012-03-05 12:28:00

#!/bin/bash
#Filename:install_php.sh
#Desc:Auto install php
#Created By:xiaozhenggang(fedoracle)
#Date:2012/03/02

PHP_HOME=/usr/local/php
PHP_SRC=/usr/local/src

#function install_packages()
#{   
#}


#check usage for this script
if [ $# -ne 1 ];then
   echo "Usage:./$0 php-x.x.xx.tar.gz"
   exit 1
fi

#check user is root or not
if [ $UID -ne 0 ];then
   echo "This script must be executed by root!Please change to user root!"
   exit 2
fi

#check php installed or not,if installed,remove it.
/bin/rpm -qa|grep php
if [ $? -eq 0 ];then
   /usr/bin/yum -y remove php
   echo "Php exists,remove it!"
else
   echo "Php does not exists."
fi

#install development tools
for package in gcc gcc-c++ flex autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtif-devel freetype-devel libXpm-devel gettext-devel pam-devel libtool libtool-ltdl libtool-ltdl-devel openssl openssl-devel fontconfig-devel libxml2 libxml2-devel curl-devel libicu libicu-devel mysql-devel libxslt libxslt-devel
do
   /usr/bin/yum -y install $package
done

cd $PHP_SRC
#install libmcrypt libmcrypt-devel limhash libmhash
if [ -s libmcrypt-2.5.7.tar.gz ];then
   echo "libmcrypt-2.5.7 exists,Now start install"
else
   echo "libmcrypt-2.5.7.tar.gz not exists,Now downloading"
   /usr/bin/wget -c ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/old/libmcrypt-2.5.7.tar.gz
fi

/bin/tar -xvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
echo "Starting make and make install"
/bin/sleep 5
make&&make install
/bin/ln -s /usr/local/lib/libmcrypt.a /usr/lib/libmcrypt.a 
/bin/ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la 
/bin/ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so 
/bin/ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
/bin/ln -s /usr/local/lib/libmcrypt.so.4.3.0 /usr/lib/libmcrypt.so.4.3.0
/bin/ln -s /usr/local/lib/libmcrypt.so.4.4.7 /usr/lib/libmcrypt.so.4.4.7
echo "Install ended"
/bin/sleep 5

/sbin/ldconfig

if [ -s mhash-0.9.9.9.tar.bz2 ];then
   echo "mhash-0.9.9.9.tar.bz2 exists,Now start install"
else
   echo "mhash-0.9.9.9.tar.bz2 not exists,Now downloading"
   /usr/bin/wget -c http://ncu.al.sourceforge.net/project/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz
fi

/bin/tar -xvf mhash-0.9.9.9.tar.bz2
cd mhash-0.9.9.9
./configure
echo "Starting make and make install"
/bin/sleep 5
make&&make install
echo "Install ended"
/bin/sleep 5
cd ../

/bin/ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
/bin/ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
/bin/ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
/bin/ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
/bin/ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/llib/libmhash.so.2.0.1

/sbin/ldconfig

if [ -s mcrypt-2.6.8.tar.gz ];then
   echo "mcrypt-2.6.8.tar.gz exists,Now install"
else
   echo "mcrypt-2.6.8.tar.gz not exists,Now downloading"
   /usr/bin/wget -c http://ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz
fi

/bin/tar -xvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8.tar.gz
./configure
echo "Starting make and make install"
/bin/sleep 5
make&&make install
echo "Install ended"
/bin/sleep 5

/sbin/ldconfig

#install php
cd $PHP_SRC
if [ -s $1 ];then
   echo "$1 exists,Now start install"
else
   echo "$1 not exists,Now downloading"
   /usr/bin/wget -c
fi

/bin/tar xvf $1
export LDFLAGS=-L/usr/lib64/mysql
VERSION=`/bin/ls -l | grep php | grep -v "tar" | grep "[0-9]$" | awk '{print $9}'`
cd $VERSION

echo "Start configuration"
/bin/sleep 5
./configure --prefix=$PHP_HOME --with-apxs2=/usr/local/apache/bin/apxs --enable-cgi --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-config-file-path=/usr/local/php/etc --enable-zip --enable-sqlite-utf8 --enable-sockets --enable-soap --enable-pcntl --enable-mbstring --enable-intl --enable-calendar --enable-bcmath --enable-exif --with-mcrypt --with-mhash --with-gd --with-png-dir --with-jpeg-dir --with-freetype-dir --with-libxml-dir --with-curl --with-curlwrappers --with-zlib --with-openssl --with-kerberos=shared --with-gettext=shared --with-xmlprc=shared --with-xsl --without-iconv

echo "Configure ended,Now start make and make install"
/bin/sleep 10

make&&make install

if [ $? -eq 0 ];then
   echo "$VERSION installed successful!!!"
   /bin/sleep 10
else
   echo "Install $VERSION failed!Please check it out and try again!"
   exit 3
fi

/bin/cp php.ini-production /usr/local/php/etc/php.ini


#merge php and apache
/bin/sed -i '/^\ \ \ \ AddType\ application\/x-gzip/a\    AddType application/x-httpd-php .php\' /usr/local/apache/conf/httpd.conf
/bin/sed -i 's/DirectoryIndex\ index.html/DirectoryIndex index.html index.php index.html/' /usr/local/apache/conf/httpd.conf

#configure Zend Gurd Loader for php-5.3.x
cd $PHP_SRC
if [ -s ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz ];then
   echo "File exists,now start install"
else 
   /usr/bin/wget -c
fi

mkdir -p /usr/local/php/zend
/bin/tar -xvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz 
/bin/cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/local/php/zend

cat<>/usr/local/php/etc/php.ini
[Zend.Loader]
zend_extension="/usr/local/php/zend/ZendGuardLoader.so"
zend_loader.enable=1
EOF


阅读(3112) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~