#!/bin/bash
LANG=C
#httpd:httpd-2.2.25.tar.gz
#mysql:mysql-5.1.62.tar.gz
#php:php-5.4.19.tar.gz
file=/usr/src/
sed -i '/SELINUX=/s/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
setenforce 0
iptables -F
service iptables save
chkconfig iptables off
yum clean all;yum list
yum clean all;yum list
yum -y remove httpd mysql-server mysql php php-mysql php-pdo php-mbstring
rm -rf /var/lib/mysql/ /etc/my.cnf
yum -y install gcc-c++ openssl-devel elinks lftp
cd $file
yum -y install gcc-c++ openssl-devel
tar -zxf httpd-2.2.25.tar.gz -C /usr/src/
cd /usr/src/httpd-2.2.25
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-cgi --enable-charset-lite --enable-ssl --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/usr/local/httpd/htdocs 2> $file/httpd.error
make 2>> $file/httpd.error
make install 2>> $file/httpd.error
/bin/cp -f /usr/local/httpd/bin/apachectl /etc/init.d/httpd
sed -i '98a ServerName mail.tarena.com:80' /usr/local/httpd/conf/httpd.conf
chkconfig --add httpd
chmod +x /etc/init.d/httpd
cd $file
yum -y install ncurses-devel libtermcap-devel
useradd -M -u 49 -s /sbin/nologin mysql
tar -zxf mysql-5.1.62.tar.gz -C /usr/src/
cd /usr/src/mysql-5.1.62
./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charset=gbk,gb2312 2> $file/mysql.error
make 2>> $file/mysql.error
make install 2>> $file/mysql.error
cd /var/ftp/pub/mysql-5.1.62/support-files/
/bin/cp my-medium.cnf /etc/my.cnf
cd /usr/local/mysql/bin/
./mysql_install_db --user=mysql &
chown -R root:mysql /usr/local/mysql/
chown -R mysql /usr/local/mysql/var/
ln -s /usr/local/mysql/bin/* /usr/local/bin/
ln -s /usr/local/mysql/lib/mysql/* /usr/lib64/
ln -s /usr/local/mysql/include/mysql/* /usr/include/
cd /usr/src/mysql-5.1.62/support-files/
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
cd $file
yum -y install libxml2-devel
tar -zxf php-5.4.19.tar.gz -C /usr/src/
cd /usr/src/php-5.4.19
./configure --prefix=/usr/local/php --enable-mbstring --enable-sockets --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php 2> $file/php.error
make 2>> $file/php.error
make install 2>> $file/php.error
cp -f php.ini-development /usr/local/php/php.ini
sed -i 's/index.html/index.html index.php/' /usr/local/httpd/conf/httpd.conf
sed -i '310a AddType application/x-httpd-php .php' /usr/local/httpd/conf/httpd.conf
/bin/echo -e "<?php\nphpinfo();\n?>" >> /usr/local/httpd/htdocs/test.php
/etc/init.d/httpd start
/etc/init.d/mysqld start
> $file/lamp.error
echo -e "php.error" >> $file/lamp.error ; cat $file/php.error >> $file/lamp.error
echo -e "\n\nhttp.error" >> $file/lamp.error ; cat $file/httpd.error >> $file/lamp.error
echo -e "\n\nmysql.error" >> $file/lamp.error ;cat $file/mysql.error >> $file/lamp.error
rm -rf $file/php.error $file/httpd.error $file/mysql.error
/usr/bin/elinks --dump http://localhost/test.php