yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel \
freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-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 libtool \
libtool-libs libevent-devel libevent openldap openldap-devel nss_ldap openldap-clients \
openldap-servers libtool-ltdl libtool-ltdl-devel bison cmake



useradd -s /sbin/nologin -r -M mysql

tar xvf mysql-5.5.22.tar.gz
cd mysql-5.5.22
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/  \
 -DSYSCONFDIR=/etc \
 -DMYSQL_DATADIR=/usr/local/mysql/data  \
 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock  \
 -DWITH_INNOBASE_STORAGE_ENGINE=1  \
 -DWITH_MYISAM_STORAGE_ENGINE=1  \
 -DENABLED_LOCAL_INFILE=1  \
 -DMYSQL_TCP_PORT=3306  \
 -DEXTRA_CHARSETS=all \
 -DDEFAULT_CHARSET=utf8 \
 -DDEFAULT_COLLATION=utf8_general_ci  \
 -DWITH_DEBUG=0  \
 -DWITH_READLINE=1  \
 -DWITH_SSL=yes \
 -DMYSQL_USER=mysql
 
 make
 make install
 
 
 cd /usr/local/mysql/data
 chown -R mysql:mysql .
 
 cd ..
 scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
 mv /etc/my.cnf /etc/my.cnf.bak
 cp support-files/my-medium.cnf /etc/my.cnf
 cp support-files/mysql.server /etc/init.d/mysqld
 service mysqld start
 
 cp /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
 
 
 
 
 
tar xvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr
make && make install


tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
 ./configure --prefix=/usr
make
make install
echo "/usr/lib" >> /etc/ld.so.conf
/sbin/ldconfig

cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then
    ln -s /usr/lib/libmcrypt.la /usr/lib64/libmcrypt.la
    ln -s /usr/lib/libmcrypt.so /usr/lib64/libmcrypt.so
    ln -s /usr/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
    ln -s /usr/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
    ln -s /usr/lib/libiconv.so.2 /usr/lib64/libiconv.so.2
if
ldconfig

tar xvf mhash-0.9.9.9.tar.bz2
cd mhash-0.9.9.9
./configure --prefix=/usr
make
make install
if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then
    ln -s /usr/lib/libmhash.a /usr/lib64/libmhash.a
    ln -s /usr/lib/libmhash.la /usr/lib64/libmhash.la
    ln -s /usr/lib/libmhash.so /usr/lib64/libmhash.so
    ln -s /usr/lib/libmhash.so.2 /usr/lib64/libmhash.so.2
    ln -s /usr/lib/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
if
ldconfig

tar xvf  mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
./configure --prefix=/usr
make
make install

if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then
ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
ln -s /usr/lib64/libldap.so /usr/lib/libldap.so
ln -s /usr/lib64/libpng.so /usr/lib/libpng.so
if


tar xvf php-5.3.10.tar.bz2
cd php-5.3.10
./configure  \
    --prefix=/usr/local/php \
    --enable-fastcgi \
    --enable-fpm \
    --enable-discard-path \
    --enable-force-cgi-redirect \
    --with-config-file-path=/usr/local/php/etc \
    --with-mysql=/usr/local/mysql \
    --with-mysqli=/usr/local/mysql/bin/mysql_config \
    --with-iconv-dir \
    --with-freetype-dir \
    --with-jpeg-dir \
    --with-png-dir \
    --with-gd \
    --with-zlib \
    --with-libxml-dir \
    --with-curl \
    --with-curlwrappers \
    --with-openssl \
    --with-mhash \
    --with-xmlrpc \
    --with-mcrypt \
    --with-ldap \
    --with-ldap-sasl \
    --enable-xml \
    --disable-rpath \
    --enable-discard-path \
    --enable-safe-mode \
    --enable-bcmath \
    --enable-shmop \
    --enable-sysvsem \
    --enable-inline-optimization \
    --enable-mbregex \
    --enable-mbstring \
    --enable-gd-native-ttf \
    --enable-ftp \
    --enable-pcntl \
    --enable-sockets \
    --enable-zip \
    --disable-debug \
    --disable-ipv6
   
   
make ZEND_EXTRA_LIBS='-liconv'
make install
cp -f php.ini-production /usr/local/php/etc/php.ini



wget http://pear.php.net/go-pear.phar
/usr/local/php/bin/php go-pear.phar

tar xvf 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
make
make install
cat >> /usr/local/php/etc/php.ini <<EOF
extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so
EOF

tar xvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make && make install

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="32"
eaccelerator.cache_dir="/data/cache/ea"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
EOF




tar xvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/php/lib/php/extensions/

cat >> /usr/local/php/etc/php.ini <<EOF
zend_loader.enable=1
zend_extension=/usr/local/php/lib/php/extensions/ZendGuardLoader.so
EOF