Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2860789
  • 博文数量: 178
  • 博客积分: 2076
  • 博客等级: 大尉
  • 技术积分: 2800
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-10 10:50
文章分类

全部博文(178)

文章存档

2010年(4)

2009年(13)

2008年(161)

我的朋友

分类: LINUX

2009-12-13 14:14:02

#!/bin/bash
################################################################################
########################this script is install the php+fastcgi enviroment ######
########################make by xiao, copyright by xiao#########################
# soft list
#-rw-r--r--  1 root root  4513309 Dec 10 10:34 libiconv-1.12.tar.gz
#-rw-r--r--  1 root root  1335178 Dec 10 10:34 libmcrypt-2.5.8.tar.gz
#-rw-r--r--  1 root root  4722227 Dec 10 10:34 libxml2-2.6.32.tar.gz
#-rw-r--r--  1 root root   512525 Dec 10 10:34 mcrypt-2.6.7.tar.gz
#-rw-r--r--  1 root root   919622 Dec 10 10:34 mhash-0.9.9.tar.gz
#-rw-r--r--  1 root root 25058473 Dec 10 10:34 mysql-standard-5.0.19-linux-i686-glibc23.tar.gz
#-rw-r--r--  1 root root   605698 Dec 10 10:34 nginx-0.8.15.tar.gz
#-rw-r--r--  1 root root   598789 Dec 10 10:34 nginx-0.8.9.tar.gz
#-rw-r--r--  1 root root  1167026 Dec 10 10:34 pcre-7.7.tar.gz
#-rw-r--r--  1 root root  1168513 Dec 10 10:34 pcre-7.8.tar.gz
#-rw-r--r--  1 root root   204248 Dec 10 10:34 php-5.2.8-fpm-0.5.10.diff.gz
#-rw-r--r--  1 root root 12427411 Dec 10 10:34 php-5.2.8.tar.gz
#-rw-r--r--  1 root root   269238 Dec 10 10:34 xcache-1.2.2.tar.gz
#-rw-r--r--  1 root root  9750649 Dec 10 10:34 ZendOptimizer-3.3.0-linux-glibc21-i386.tar.gz
#-rw-r--r--  1 root root 1596755 Dec 10 11:08 freetds-stable.tgz
#var-values
useage()
{
echo "sh install.sh -----just do it --ok? donot ask it againt "
exit 0
}
SOURCE=/root/SOURCE
groupadd mysql
useradd -g mysql mysql
groupadd www
useradd -g www www
#apply
cd $SOURCE
if [ $# -gt 0 ] ; then
useage
fi
tarx()
{
cd $SOURCE;
tar -xzvf freetds-stable.tgz
rm -rf $SOURCE/php-5.2.8
for i in `ls -l $SOURCE/*.tar.gz |awk '{print $9}'`
do
tar -xzvf $i
done
}
tarx
install_libiconv()
{
echo "##################################install libiconv"
echo "##################################################"
echo "##################################################"
cd libiconv-1.12/
./configure --prefix=/usr/local
  make && make install
if [ $? -ne "0" ] ; then
 echo "install libiconv error">> /root/record.txt && exit 1
#return $?
fi
#&& echo "install libiconv compelete">> /root/record.txt || exit 1
}
install_libmcrypt()
{
echo "################################## libmcrypt   ######"
echo "##################################################"
echo "##################################################"
cd $SOURCE
pwd
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
if [ $? -ne "0" ] ; then
 echo "install libmcrypt error">> /root/record.txt && exit 1
#return $?
else
ln -fs /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -fs /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -fs /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -fs /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -fs /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -fs /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -fs /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -fs /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -fs /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
fi
#&& echo "install libmcrypt worong"| tee -a /root/record.txt;exit 1
}
 
install_mhash()
{
echo "##################################install mhash ######"
echo "##################################################"
echo "##################################################"
cd $SOURCE
cd mhash-0.9.9/
./configure
make &&make install
if [ $? -ne "0" ] ; then
 echo "install libmhash error">> /root/record.txt && exit 1
fi
}
install_mcrypt()
{
echo "##################################install mcrypt ######"
echo "##################################################"
echo "##################################################"
cd $SOURCE
cd mcrypt-2.6.7/
/sbin/ldconfig
./configure
make && make install
if [ $? -ne "0" ] ; then
 echo "install mcrypt error">> /root/record.txt && exit 1
fi
}

install_libxml()
{
echo "##################################install libxml   ######"
echo "##################################################"
echo "##################################################"
cd $SOURCE
cd libxml2-2.6.32
./configure --prefix=/usr/local/libxml
make && make install
if [ $? -ne "0" ] ; then
 echo "install libxml error">> /root/record.txt && exit 1
fi
}
install_freetds()
{
echo "##################################install freetds   ######"
echo "##################################################"
echo "##################################################"
cd $SOURCE
cd freetds-0.82
./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld --enable-shared --enable-static
make && make install
if [ $? -ne "0" ] ; then
 echo "install freetds error">> /root/record.txt && exit 1
fi
}
install_mysql()
{
echo "##################################install mysql   ######"
echo "##################################################"
echo "##################################################"
if [ ! -d /usr/local/mysql ] ; then
ln -sf /usr/local/mysql-standard-5.0.19-linux-i686-glibc23 /usr/local/mysql
cd /usr/local/mysql
scripts/mysql_install_db --user=mysql
      chown -R root  .
      chown -R mysql data
      chgrp -R mysql .
      bin/mysqld_safe --user=mysql &
else
echo "*********************************************************************************"
echo "*******************************MYSQL ALREADY INSTALLED***************************"
fi
}
 
install_php()
{
echo "################################## PHPINSTALL   ######"
echo "##################################################"
echo "##################################################"
cd $SOURCE
yum -y install freetype-devel
yum -y install libpng-devel
yum -y install curl-devel
yum -y install libxml2-devel
yum -y install libjpeg-devel
pwd
gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1
cd php-5.2.8/
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib  --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets    --with-mssql=/usr/local/freetds
make && make install
cp $SOURCE/php-5.2.8/php.ini-dist /usr/local/php/etc/php.ini
if [ $? -ne "0" ] ; then
 echo "install PHP error">> /root/record.txt && exit 1
fi
sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"#' /usr/local/php/etc/php.ini
sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/php/etc/php.ini
}
 

install_ZendOptimizer()
{
echo "##################################install ZendOptimizer ######"
echo "##################################################"
echo "##################################################"
cd $SOURCE
./ZendOptimizer-3.3.0-linux-glibc21-i386/install.sh
return $?
}
 
install_nginx()
{
echo "##################################install nginx ######"
echo "##################################################"
echo "##################################################"
cd $SOURCE
cd  pcre-7.8/ 
./configure
make && make install
if [ $? -ne "0" ] ; then
 echo "install pcre error">> /root/record.txt && exit 1
fi
cd $SOURCE
cd nginx-0.8.15
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
if [ $? -ne "0" ] ; then
 echo "install nginx error">> /root/record.txt && exit 1
fi
return $?
}
configure_phpcgi()
{
if [ -f /usr/local/php/etc/php-fpm.conf.old ] ; then
    rm -rf /usr/local/php/etc/php-fpm.conf.old
else
mv /usr/local/php/etc/php-fpm.conf /usr/local/php/etc/php-fpm.conf.old
cp -rf /root/scripts/php-fpm.conf /usr/local/php/etc/php-fpm.conf
fi
}
configure_nginx()
{
if  [ -d /usr/local/nginx/conf.dd ] ; then
    rm -rf /usr/local/nginx/conf.dd
else
mv /usr/local/nginx/conf /usr/local/nginx/conf.dd
\cp -rf /root/scripts/conf /usr/local/nginx/
fi
}
start_php_cgi()
{
/usr/local/php/sbin/php-fpm start
#check process code belove here
}
start_nginx()
{
if [ ! -f  /home/www/app/test ] ; then
 mkdir -p /home/www/app/test
fi
chown -fR /home/www
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx
#check process code belove here
}
##########################################################################
install_libiconv
install_libmcrypt
install_mhash
install_mcrypt
install_libxml
install_freetds
install_mysql
install_php
install_ZendOptimizer
if [ $? -ne "0" ] ; then
echo "php return 1"
exit1
fi
configure_phpcgi
install_nginx
if [ $? -ne "0" ] ; then
echo "nginx return 1"
exit1
fi
configure_nginx
start_php_cgi
start_nginx
#############################################
 
 
 
result:::::::::::::::
 
 
23493 www       25   0    0   0:00.00  0.1 22244 4324 1512 S php-cgi                                                               
23494 www       25   0    0   0:00.00  0.1 22244 4324 1512 S php-cgi                                                               
23495 www       25   0    0   0:00.00  0.1 22244 4324 1512 S php-cgi                                                               
23496 www       25   0    0   0:00.00  0.1 22244 4324 1512 S php-cgi                                                               
23497 www       25   0    0   0:00.00  0.1 22244 4324 1512 S php-cgi                                                               
23498 www       25   0    0   0:00.00  0.1 22244 4324 1512 S php-cgi                                                               
23499 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23500 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23501 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23502 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23503 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23504 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23505 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23506 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23507 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23508 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23509 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23510 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23511 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23512 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23513 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23514 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23515 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23516 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23517 www       25   0    0   0:00.00  0.1 22244 4328 1512 S php-cgi                                                               
23590 www       16   0    0   0:00.01  0.3 16188  10m  832 S nginx                                                                 
23591 www       15   0    0   0:00.01  0.3 16188  10m  588 S nginx                                                                 
23592 www       15   0    0   0:00.01  0.3 16188  10m  588 S nginx                                                                 
23593 www       15   0    0   0:00.01  0.3 16188  10m  588 S nginx                                                                 
23594 www       15   0    0   0:00.01  0.3 16188  10m  588 S nginx                                                                 
23595 www       15   0    0   0:00.01  0.3 16188  10m  588 S nginx                                                                 
23596 www       15   0    0   0:00.01  0.3 16188  10m  588 S nginx                                                                 
23597 www       15   0    0   0:00.01  0.3 16188  10m  584 S nginx                                                                 
阅读(647) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-11-30 10:12:53

thank you