在编译安装之前先安装:yum install -y gcc  epel-release


mysql的编译安装

#cd /usr/local/src

#wget http://mirrors.sohu.com/mysql/Mysql-5.1/mysql-5.1.73-linux-i686-glibc23.tar.gz

#tar zxvf mysql-5.1.73-linux-i686-glibc23.tar.gz

#mv mysql-5.1.73-linux-i686-glibc23 ../mysql

#useradd -M -s /sbin/nologin mysql

#cd /usr/local/mysql

#mkdir -p /data/mysql

#chown -R mysql:mysql /data/mysql

#./scripts/mysql_db--user=mysql --datadir=/data/mysql


拷贝配置文件和启动文件

#cp support-files/my_large.cnf /etc/my.cnf

#cp support-files/mysql.server /etc/init.d/mysqld

#chmod 755 /etc/init.d/mysqld


修改启动脚本

#vim /etc/init.d/mysqld

修改:datadir=/data/mysql

    basedir=/usr/lcoal/mysql

:wq

#chkconfig --add mysqld

#chkconfig mysqld on



apache的编译安装:

#cd /usr/local/src

#wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.31.tar,gz

#tar zxvf http-2.2.31.tar.gz

#cd http-2.2.31

#./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre

#make && make install



php编译安装

#yum install -y libxml2-devel  openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel libmcrypt-devel   ##为了防止编译时出错


#cd /usr/local/src

#wget http://mirrors.sohu.com/php/php-5.4.44.tar.bz2

#tar xjvf php-5.4.44.tar.bz2

#cd php-5.4.44

#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc  --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6

#make && make install


#cp php.ini-production /usr/local/php/etc/php.ini


修改httpd配置文件

#vim /usr/local/apache2/conf/httpd.conf

找到:AddType application/x-gzip.gz .tgz

在该行下面添加:

        AddType application/x-htppd-php .php

找到修改:DirectoryIndex index.html index.htm index.php

找到修改:ServerName localhost:80