mkdir -v /home/software
mkdir -v /tmp/apachecache
chown daemon:daemon /tmp/apachecache
chmod 744 /tmp/apachecache
cd /home/software
wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.13.tar.gz
wget http://labs.renren.com/apache-mirror/httpd/httpd-2.2.16.tar.bz2
wget ftp://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.1/mysql-5.1.49.tar.gz
wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2

#1.apache
解压
tar xvf httpd-2.2.16.tar.bz2
cd httpd-2.2.16
./configure --prefix=/usr/local/apache2.2 --enable-mods-shared=most --enable-so --enable-cache --enable-disk-cache --enable-mem-cache --enable-rewrite --enable-ssl
#./configure --prefix=/usr/local/gserver/apache2 --enable-mods-shared=most --enable-so --enable-cache --enable-disk-cache --enable-mem-cache --enable-rewrite --enable-ssl

## 安装到/usr/local/apache2.2.15,把大部分功能编译成模块,rewrite,diskcache等.
make
make install
echo "export PATH=\$PATH:/usr/local/apache2/bin" >> /etc/profile
echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.local
#较常出现问题:No recognized SSL/TLS toolkit detected
#解决办法:安装openssl-devel
#启动Apache出现“error while loading shared libraries: libiconv.so.2”
#解决方法:echo "/usr/local/lib" >> /etc/ld.so.conf
#ldconfig


#2.Mysql
tar xvf mysql-5.1.49.tar.gz
cd mysql-5.1.49
./configure --with-mysqld-user=mysql --prefix=/usr/local/mysql5.1 --with-extra-charsets=all --exec-prefix=/usr/local/mysql5.1 --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-plugins=partition

##   --with-mysqld-user=mysql:以mysql用户的身份运行mysqld进程
##   --with-extra-charsets=all:支持所有字符集
##   --exec-prefix=/usr/local/mysql:mysql的执行文件安装位置,会在mysql目录下产生bin目录
##   --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static:静态编译 mysql
##   --with-plugins=partition:支持分区

##出现错误No curses/termcap library found
##解决办法:安装Ncurses
##有时间出现configure: error: No curses/termcap library found
##解决办法:
##   autoreconf --force --install
##   libtoolize --automake --force
##   automake --force --add-missing

make
make install
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 700 /etc/init.d/mysqld
#数据库的初始化
/usr/local/mysql5.1/bin/mysql_install_db

chown mysql /usr/local/mysql5.1/ -R
chown mysql:mysql /usr/local/mysql5.1/var -R
/usr/local/mysql5.1/bin/mysqld_safe --user=mysql &
echo "/usr/local/mysql5.1/bin/mysqld_safe --user=mysql &" >> /etc/rc.local
echo "export PATH=\$PATH:/usr/local/mysql5.1/bin" >> /etc/profile
#修改端口和密码
cp /home/software/mysql-5.1.49/support-files/my-large.cnf /etc/my.cnf
mysqladmin -u root passwordJOYSQL5.1
#允许远程登陆
grant all privileges on *.* to 'root'@'%' identified by 'JOYSQL5.1' with grant option;


#3.php
tar xvf php-5.2.13.tar.gz
cd php-5.2.13
./configure --prefix=/usr/local/php5.2 --with-apxs2=/usr/local/apache2.2/bin/apxs --with-mysql=/usr/local/mysql5.1 --with-config-file-path=/usr/local/php5.2

##   --with-apxs2=/usr/local/apache2/bin/apxs:用apache的apxs工具把php编译成apache的一个模块
##有时提示.configure: error: xml2-config not found. Please check your libxml2 installation. 
##解决办法:安装 libxml2

make
make install
cp php.ini-dist /usr/local/php5.2/php.ini

#4.eaccelerator php加速
tar xvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
mkdir -v /home/eaccelerator
chmod 777 /home/eaccelerator
/usr/local/php5.2/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php5.2/bin/php-config
make
make install

#5.evasive  防DDos攻击
tar xvf mod_evasive_1.10.1.tar.gz
cd mod_evasive
/usr/local/apache2.2/bin/apxs -i -a -c mod_evasive20.c
echo "/usr/local/apache2.2/modules/mod_evasive20.so" /etc/ld.so.conf
ldconfig


##
" Syntax error on line xxx of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied "
解决办法
chcon -t texrel_shlib_t path_to _you_moulde_dir/libphp5.so