Linux下Apache 2.2, MySQL 5.0和PHP 5.0的安装与配置

1.安装环境
操作系统:Red Hat Linux Enterprise AS 4.0
数据库:MySQL 5.0.24
Web服务器:Apache 2.2.3
脚本语言:PHP 5.1.6

2.安装MySQL 5.0.24
-------------下载软件包mysql-5.0.24.tar.gz,地址http://www.mysql.com-------------
# tar zvxf mysql-5.0.24.tar.gz //解压缩
# cd mysql-5.0.24 //进入解压缩后的文件目录
# ./configure --prefix=/usr/local/mysql \ //设定安装目录
--enable-thread-safe-client \ //编译线程安全版的客户端库
--without-debug \ //关闭debug功能
--localstatedir=/data/mysqldata \ //设定数据库文件目录
# make //编译
# make install //安装
# /usr/local/mysql/bin/mysql_install_db //初始化授权
# chown –R root:root /usr/local/mysql //文件属性改为root用户
# cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf //复制配置文件
----------------------------------启动MySQL服务----------------------------------
# /usr/local/mysql/bin/mysqld_safe --user=root & //启动MySQL
----------------------------------修改MySQL密码----------------------------------
# /usr/local/mysql/bin/mysqladmin -uroot password mysqlsecret //修改密码
----------------------------------关闭MySQL服务----------------------------------
# /usr/local/mysql/bin/mysqladmin -uroot -pmysqlsecret shutdown //关闭MySQL

3.安装Apache 2.2.3
-------------下载软件包httpd-2.2.3.tar.gz,地址http://www.apache.org-------------
# tar zvxf httpd-2.2.3.tar.gz
# cd httpd-2.2.3
# ./configure --prefix=/usr/local/apache \
--enable-module=most \
--enable-shared=max
# make
# make install
----------------------------------启动Apache服务----------------------------------
# /usr/local/apache/bin/apachectl start
----------------------------------关闭Apache服务----------------------------------
# /usr/local/apache/bin/apachectl stop
----------------------------------重启Apache服务----------------------------------
# /usr/local/apache/bin/apachectl restart

4.安装PHP 5.1.6
-------------------下载软件包php-5.1.6.tar.gz,地址www.php.net--------------------
# tar zvxf php-5.1.6.tar.gz
# cd php-5.1.6
# ./configure --prefix=/usr/local/php \
--with-mysqld=/usr/local/mysql \
--with-apxs2=/usr/local/apache/bin/apxs
# make
# make install
# cp php.ini-dist /usr/local/php/lib/php.ini

5.配置Apache服务的httpd.conf文件
*在LoadModule处添加 LoadModule php5_module module/libphp5.so
*在DirectoryIndex处添加 index.php
*在AddType application处添加
AddType application/x-httpd-php .php .phtml
AddType applicatoin/x-httpd-php-source .phps