#!/bin/bash
#
# vm test install script
#
# create by xk
#
# data 2013-04-25
#
#
SOFTPATH=/home/tools
PROGRAMPATH=/export/servers
#Usage
show_usage() {
echo "$0 {php|nginx|libmcrypt|all}"
}
if [ $# -ne ]; then
show_usage
fi
#check dict
if [ !-d ${PEOGRAMPATH} ] ;then
mkdir -p ${PEOGRAMPATH}
fi
cd ${SOFTPATH}
unzip vm_test.zip
cd software
#update package
yum install -y libxml2 libxl2-devel curl-devel mysql mysql-devel
ln -s /usr/lib64/mysql/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so
nginx_fun() {
tar xvf pcre-8.30.tar.bz2
cd pcre-8.30
./configure
make && make install
cd ../
tar xvf nginx-1.2.3.tar.gz
cd nginx-1.2.3
./configure --prefix=${PROGRAMPATH}/nginx-1.2.3 \
--with-pcre=../pcre-8.30
make && make install
cd ../
#cp file
cp nginx.conf ${PROGRAMPATH}/nginx-1.2.3/conf/nginx.conf
cp search.conf ${PROGRAMPATH}/nginx-1.2.3/conf/search.conf
cp php-fpm.conf ${PROGRAMPATH}/php-5.3.17/etc/php-fpm.conf
#mkdir data
mkdir -p /export/data/www
cp search.360buy.com.tar.gz /export/data/www
cd /export/data/www && tar zxvf search.360buy.com.tar.gz
#add user
useradd www
#star nginx php
${PROGRAMPATH}/php-5.3.17/sbin/php-fpm
${PROGRAMPATH}/nginx-1.2.3/sbin/nginx
}
libmcrypt_fun() {
tar xvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure prefix=${PROGRAMPATH}/libmcrypt
make
make install
cd ../
}
# php install
php_fun() {
#php install
tar xvf php-5.3.17.tar.bz2
cd php-5.3.17
./configure --prefix=${PROGRAMPATH}/php-5.3.17 \
--with-config-file-path=${PROGRAMPATH}/php-5.3.17/etc \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-mbstring \
--with-curl \
--with-mcrypt=${PROGRAMPATH}/libmcrypt \
--with-mysql=/usr/local/mysql \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv
make
make install
cd ../
#eaccelerator
#tar jxvf eaccelerator-0.9.6.1.tar.bz2
#cd eaccelerator-0.9.6.1/
#${PROGRAMPATH}/php-5.3.17/bin/phpize
#./configure --enable-eaccelerator=shared --with-php-config=/export/servers/php-5.3.17/bin/php-config
#make && make install
#cd ../
cp php.ini ${PROGRAMPATH}/php-5.3.17/etc/
}
case $1 in
nginx)
nginx_fun
;;
php)
php_fun
;;
libmcrypt)
libmcrypt_fun
;;
all)
libmcrypt_fun
php_fun
nginx_fun
;;
*)
;;
esac