一.查看组软件包安装情况
 yum grouplist | less  //查看确保五组包要被安装上
Development Libraries
Development Tools
X Software Development
Legacy Software Development
Java Development

 二.安装mysql

 1.安装准备

 [root@localhost ~]# tar -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local/

[root@localhost ~]# cd /usr/local/mysql-5.5.15-linux2.6-i686

[root@localhost mysql-5.5.15-linux2.6-i686]# less INSTALL-BINARY
文件内容:
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
 
2.安装过程
[root@localhost local]# ln -s mysql-5.5.15-linux2.6-i686/ mysql
[root@localhost local]# cd mysql
[root@localhost mysql]# groupadd mysql
[root@localhost mysql]# useradd -r -g mysql mysql
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# scripts/mysql_install_db --user=mysql //以mysql身份运行初始化脚本[root@localhost mysql]# chown -R root .   //所有者改回来
[root@localhost mysql]# chown -R mysql data
[root@localhost mysql]# cp support-files/my-medium.cnf /etc/my.cnf
[root@localhost mysql]# bin/mysqld_safe --user=mysql & //启动服务
[root@localhost mysql]# netstat -tupln |grep mysql
tcp        0      0 :::3306       :::*        LI STEN      4549/mysqld
换成常用方式启动服务:
[root@localhost mysql]cp support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# service mysqld stop
Shutting down MySQL.                                       [确定]
[root@localhost mysql]# netstat -tupln |grep mysql
[root@localhost mysql]# service mysqld start
Starting MySQL..                                           [确定]
[root@localhost mysql]# netstat -tupln |grep mysql
tcp        0      0 :::3306       :::*           LISTEN      5544/mysqld        
[root@localhost mysql]# chkconfig --list |grep mysql
[root@localhost mysql]# vim /etc/init.d/mysqld
# chkconfig: 2345 64 36 //2345是表示on状态 64是启动号 36是终止号
[root@localhost mysql]# chkconfig --add mysqld
[root@localhost mysql]# chkconfig --list |grep mysql
mysqld                0:关闭     1:关闭     2:启用     3:启用     4:启用     5:启用     6:关闭
[root@localhost mysql]# ll /etc/rc.d/rc3.d |grep mysql
lrwxrwxrwx 1 root root 16 08-21 17:35 S64mysqld -> ../init.d/mysqld //s64是启动顺序
3.库文件说明:系统调用库一般是从 /lib ; /usr/lib ; 但是这次安装的库是在/usr/local/mysql/lib ,为非标准类型的库
需要链接到系统上去
方法:
[root@localhost mysql]# cd /etc/ld.so.conf.d
 vim mysql.conf
 文件内容加上:
/usr/local/mysql/lib
[root@localhost ld.so.conf.d]# ldconfig -v |grep mysql //查看系统是否链接上库
/usr/local/mysql/lib:
libmysqlclient.so.18 -> libmysqlclient_r.so.18.0.0   //说明库可以被调用了
4.头文件说明:mysql的头文件include也不在常见目录:/usr/include /;  因为不是标准路径,须向系统指明路径
 方法:
[root@localhost ld.so.conf.d]# cd /usr/include/
[root@localhost include]# ln -s /usr/local/mysql/include/ mysql
三.安装apache
1.[root@localhost ~]# tar -jxvf httpd-2.2.19.tar.bz2 -C /usr/local/src
2.[root@localhost httpd-2.2.19]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl   --with-z
说明:--prefix //安装路径  
            --sysconfdir //配置文件位置
            --enable-so //形成动态链接库
            --enable-ssl //支持ssl功能
            --with-z //确保安装了zlib
3.[root@localhost httpd-2.2.19]#make           //生成文件
4. [root@localhost httpd-2.2.19]#make install //把生成的文件放到相应的位置
    [root@localhost ~]# cd /usr/local/apache/bin
    [root@localhost bin]# ./apachectl start     //执行脚本,启动服务
    [root@localhost bin]# netstat -tupln |grep 80
tcp        0      0 :::80                       :::*       LISTEN      29847/httpd
5.设置成为开机启动
vim /etc/rc.d/rc.local //开机脚本
文件内容加上:
/usr/local/apache/bin/apachectl start
6.库文件
[root@localhost bin]# cd /etc/ld.so.conf.d
[root@localhost ld.so.conf.d]# vim httpd.conf
文件内容:
/usr/local/apache/lib
[root@localhost ld.so.conf.d]# ldconfig -v
[root@localhost ld.so.conf.d]# ldconfig -vp |grep apr
7.头文件
[root@localhost ld.so.conf.d]# cd /usr/include/
[root@localhost include]# ln -s /usr/local/apache/include/ apache
测试
客户端访问站点:

  

四.安装php
1. [root@localhost ~]# tar -jxvf php-5.3.7.tar.bz2 -C /usr/local/src
    [root@localhost ~]# cd /usr/local/src/php-5.3.7/
2.[root@localhost php-5.3.7]#./configure  --prefix=/usr/local/php  --with-apxs2=/usr/local/apache/bin/apxs   --with-mysql=/usr/local/mysql  --with-mysqli=/usr/local/mysql/bin/mysql_config   --enable-mbstring=all
说明:--with-apxs2=/usr/local/apache/bin/apxs //将php编译成apache的模块,允许apache的apxx调用该模块
      --with-mysql=/usr/local/mysql //指明mysql的安装位置
      --with-mysqli=/usr/local/mysql/bin/mysql_config //调用myql接口
[root@localhost php-5.3.7]# make
[root@localhost php-5.3.7]# make install
五.测试
1.[root@localhost ~]#cd /usr/local/apache/htdocs // apache 站点主目录
vim index.html
文件内容加入:
<html><body><h1>It works!</h1></body></html>
<?php
phpinfo();
?>
[root@localhost htdocs]# mv index.html index.php
2.vim /etc/httpd/httpd.conf
文件内容加入:
166 AddType application/x-httpd-php .php  //apache需要加入这句话才能处理php页面
168 加入index.php    //rpm包安装apache服务不需要加入这句话
3.[root@localhost ~]#/usr/local/apache/bin/apachectl start //启动apache服务
测试通过nginx调用php:
4.vim index.html
文件内容加入:
<html><body><h1>It works!</h1></body></html>
<?php
$link=mysql_connect('127.0.0.1','root','');
if($link) echo "ok";
 else echo "no";
?>
[root@localhost ~]#/usr/local/apache/bin/apachectl stop
[root@localhost ~]#/usr/local/apache/bin/apachectl start
测试通过php调动mysql:
[root@localhost ~]#/usr/local/apache/bin/apachectl stop
4.[root@localhost ~]#/usr/local/mysql/bin/mysql //进入数据库
   [root@localhost ~]#/usr/local/mysql/bin/mysqladmin –u root –p password ‘123’ //创建帐号
   [root@localhost ~]# /usr/local/mysql/bin/mysql
   ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
   [root@localhost ~]# /usr/local/mysql/bin/mysql -u root -p  //输密码进入数据库
   Enter password:
   mysql>