## Remove
rpm -qa|grep  httpd
rpm -e httpd
rpm -qa|grep mysql
rpm -e mysql
rpm -qa|grep php
rpm -e php
yum -y remove httpd
yum -y remove php
yum -y remove mysql-server mysql
yum -y remove php-mysql
yum -y install yum-fastestmirror
yum -y remove httpd

## Disable SeLinux ##
if [ -s /etc/selinux/config ]; then
        sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config
fi

## Set timezone ##
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
yum install -y ntp
ntpdate -d cn.pool.ntp.org
date

for packages in patch make gcc gcc-c++ gcc-g77 flex bison file wget libtool libtool-libs automake autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel sendmail unzip;
do yum -y install $packages; done

## libiconv ##
tar -zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure –prefix=/usr/local
make && make install

## libevent ##
tar -zxvf libevent-2.0.12-stable.tar.gz
cd libevent-2.0.12-stable/
./configure –prefix=/usr
make && make install

## libmcrypt ##
tar -jxvf libmcrypt-2.5.8.tar.bz2
cd libmcrypt-2.5.8/
./configure
make && make install
/sbin/ldconfig
cd libltdl/
./configure –enable-ltdl-install
make && make install

## mhash ##
tar -jxvf mhash-0.9.9.9.tar.bz2
cd mhash-0.9.9.9/
./configure
make && make install

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

## mcrypt ##
tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure
make && make install

## MySQL ##
groupadd mysql
useradd -g mysql -s /sbin/nologin -M mysql
tar -zxvf mysql-5.1.59.tar.gz
cd mysql-5.1.59
./configure –prefix=/usr/local/mysql –with-extra-charsets=all –enable-thread-safe-client –enable-assembler –with-charset=utf8 –enable-thread-safe-client –with-big-tables –with-readline –with-ssl –with-embedded-server –with-plugins=innobase –enable-local-infile –without-debug
make && make install
cp -f /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
sed -i ‘s/skip-locking/skip-external-locking/g’ /etc/my.cnf
sed -i ‘s/log-bin=mysql-bin/#log-bin=mysql-bin/g’ /etc/my.cnf
sed -i ‘s/binlog_format=mixed/#binlog_format=mixed/g’ /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db –user=mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql/.
cp -f /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
chkconfig –level 345 mysql on
cat > /etc/ld.so.conf.d/mysql.conf<<EOF
/usr/local/mysql/lib/mysql
/usr/local/lib
EOF
ldconfig
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump
ln -s /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk
/etc/init.d/mysql start
/usr/local/mysql/bin/mysqladmin -u root password newpass
/etc/init.d/mysql restart
echo "DELETE FROM mysql.user WHERE Password=”" | mysql -u root -p

## Apache ##
userdel www
groupdel www
groupadd -g 888 www
useradd -u 888 -g www -s /sbin/nologin -M www
tar zxvf httpd-2.2.21.tar.gz
cd httpd-2.2.21
if [ `getconf WORD_BIT` = ’32’ ] && [ `getconf LONG_BIT` = ’64’ ]; then
rm -f configure
./buildconf
./configure –prefix=/usr/local/apache –with-mysql=/usr/local/mysql –enable-headers –enable-so –enable-rewrite –enable-ssl –with-ssl –enable-deflate –enable-expires –enable-cache –with-mpm=prefork –enable-lib64 –libdir=/usr/lib64 –disable-userdir
else
./configure –prefix=/usr/local/apache –with-mysql=/usr/local/mysql –enable-headers –enable-so –enable-rewrite –enable-ssl –with-ssl –enable-deflate –enable-expires –enable-cache –with-mpm=prefork –disable-userdir
fi
make && make install

cp -f /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd
chmod 755 /etc/init.d/httpd
echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.d/rc.local

###php install
ln -sf /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
ln -sf /usr/lib64/libpng.so /usr/lib/libpng.so
##php5.2.17
./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-apxs2=/usr/local/apache/bin/apxs –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-zlib –with-libxml-dir –with-gd –enable-gd-native-ttf –with-freetype-dir –with-jpeg-dir –with-png-dir –with-iconv –with-openssl –with-mcrypt –with-mhash –enable-ftp –enable-sockets –enable-bcmath –enable-calendar –enable-exif –enable-libxml –enable-magic-quotes –enable-mbstring –enable-zip –with-bz2 –with-curl –with-curlwrappers –enable-soap –with-xmlrpc –with-gettext –disable-debug
make ZEND_EXTRA_LIBS=’-liconv’
make install
mkdir /usr/local/php/etc
cp php.ini-recommended /usr/local/php/etc/php.ini

##php5.3

./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-apxs2=/usr/local/apache/bin/apxs –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-zlib –with-libxml-dir –with-gd –enable-gd-native-ttf –with-freetype-dir –with-jpeg-dir –with-png-dir –with-iconv –with-openssl –with-mcrypt –with-mhash –enable-ftp –enable-sockets –enable-bcmath –enable-calendar –enable-exif –enable-libxml –enable-magic-quotes –enable-mbstring –enable-zip –with-bz2 –with-curl –with-curlwrappers –enable-soap –enable-zend-multibyte –with-xmlrpc –with-gettext –disable-debug
make ZEND_EXTRA_LIBS=’-liconv’
make install
mkdir /usr/local/php/etc
cp php.ini-production /usr/local/php/etc/php.ini

#######php export and copy php.ini
ln -s /usr/local/php/etc/php.ini /etc/php.ini
ln -s /usr/local/php/bin/php /usr/bin/php
ln -s /usr/local/php/bin/phpize /usr/bin/phpize

## memcache ##
tar -zxvf memcache-2.2.6.tgz
cd memcache-2.2.6/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-zlib-dir –enable-memcache
make && make install

## PDO_MYSQL ##
tar -zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MY
SQL-1.0.2/
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr/local/mysql
make && make install

## set php.ini ##
###php5.3
sed -i ‘s#; extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"nextension = "pdo_mysql.so"nextension = "memcache.so"n#g’ /usr/local/php/etc/php.ini
sed -i ‘s/post_max_size = 8M/post_max_size = 50M/g’ /usr/local/php/etc/php.ini
sed -i ‘s/upload_max_filesize = 2M/upload_max_filesize = 50M/g’ /usr/local/php/etc/php.ini
sed -i ‘s#;date.timezone =#date.timezone = "Asia/Shanghai"#g’ /usr/local/php/etc/php.ini
sed -i ‘s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g’ /usr/local/php/etc/php.ini
sed -i ‘s/max_execution_time = 30/max_execution_time = 300/g’ /usr/local/php/etc/php.ini
sed -i ‘s/short_open_tag = Off/short_open_tag = On/g’ /usr/local/php/etc/php.ini
###php5.2
sed -i ‘s#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"nextension = "pdo_mysql.so"nextension = "memcache.so"n#g’ /usr/local/php/etc/php.ini
sed -i ‘s/post_max_size = 8M/post_max_size = 50M/g’ /usr/local/php/etc/php.ini
sed -i ‘s/upload_max_filesize = 2M/upload_max_filesize = 50M/g’ /usr/local/php/etc/php.ini
sed -i ‘s#;date.timezone =#date.timezone = "Asia/Shanghai"#g’ /usr/local/php/etc/php.ini
sed -i ‘s/; cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g’ /usr/local/php/etc/php.ini
sed -i ‘s/max_execution_time = 30/max_execution_time = 300/g’ /usr/local/php/etc/php.ini
sed -i ‘s/short_open_tag = Off/short_open_tag = On/g’ /usr/local/php/etc/php.ini

## eAccelerator ##
###php 5.3
tar -jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
#####php5.2.17
tar -jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3
/usr/local/php/bin/phpize
./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config –with-eaccelerator-shared-memory
make && make install
mkdir /tmp/eaccelerator
chmod 777 /tmp/eaccelerator
echo "mkdir /tmp/eaccelerator" >> /etc/rc.d/rc.local
echo "chmod 777 /tmp/eaccelerator" >> /etc/rc.d/rc.local
##php5.3
cat >>/usr/local/php/etc/php.ini<<EOF

[eAccelerator]
zend_extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size = "16"
eaccelerator.cache_dir = "/tmp/eaccelerator"
eaccelerator.enable = "1"
eaccelerator.optimizer = "1"
eaccelerator.check_mtime = "1"
eaccelerator.debug = "0"
eaccelerator.filter = ""
eaccelerator.shm_max = "0"
eaccelerator.shm_ttl = "3600"
eaccelerator.shm_prune_period = "3600"
eaccelerator.shm_only = "0"
eaccelerator.compress = "1"
eaccelerator.compress_level = "9"
EOF

##php5.2.17
cat >>/usr/local/php/etc/php.ini<<EOF

[eAccelerator]
zend_extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size = "16"
eaccelerator.cache_dir = "/tmp/eaccelerator"
eaccelerator.enable = "1"
eaccelerator.optimizer = "1"
eaccelerator.check_mtime = "1"
eaccelerator.debug = "0"
eaccelerator.filter = ""
eaccelerator.shm_max = "0"
eaccelerator.shm_ttl = "3600"
eaccelerator.shm_prune_period = "3600"
eaccelerator.shm_only = "0"
eaccelerator.compress = "1"
eaccelerator.compress_level = "9"
EOF

## Zend Optimizer ##
mkdir /usr/local/zend
if [ -f $source_dir/php-5.3*.check ]; then
if [ `getconf WORD_BIT` = ’32’ ] && [ `getconf LONG_BIT` = ’64’ ]; then
tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/local/zend/ZendGuardLoader.so
else
tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/zend/ZendGuardLoader.so
fi
cat >>/usr/local/php/etc/php.ini<<EOF

[Zend Optimizer]
zend_extension = "/usr/local/zend/ZendGuardLoader.so"
EOF
touch /usr/local/mapn/installed/zendoptimizer
else
if [ `getconf WORD_BIT` = ’32’ ] && [ `getconf LONG_BIT` = ’64’ ]; then
tar -zxvf ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
cp -f ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/ZendOptimizer.so
else
tar -zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
cp -f ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/ZendOptimizer.so
fi
cat >>/usr/local/php/etc/php.ini<<EOF

[Zend Optimizer]
zend_optimizer.optimization_level = "1"
zend_extension = "/usr/local/zend/ZendOptimizer.so"
EOF
touch /usr/local/mapn/installed/zendoptimizer
fi
else
cat >>/usr/local/php/etc/php.ini<<EOF

;ZendOptimizer
EOF
fi

发表评论

电子邮件地址不会被公开。 必填项已用*标注