一.先检查编译环境
[root@cms ~]# yum grouplist
需要安装的几组工具
Development Libraries (开发库)
Development Tools (开发工具)
Legacy Software Development (传统软件开发工具)
X Software Development
二.构建编译环境,使用yum安装
[root@cms ~]# yum -y groupinstall "Development Libraries" "Development Tools" "Legacy Software Development"
环境构建完毕之后我们就可以编译apache,mysql,php的源码包。这里我们使用mysql绿色安装方式,所要使用到的包我们已经准备好了:
httpd-2.2.19.tar.bz2
mysql-5.5.15-linux2.6-i686.tar.gz 绿色的软件
php-5.3.7.tar
三.安装mysql,这里使用绿色安装方式,直接解压到/usr/local重命名为mysql下即可使用
[root@cms ~]# tar -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local
[root@cms ~]# cd /usr/local #切换目录
[root@cms local]# ln -s mysql-5.5.15-linux2.6-i686 mysql #为mysql建立一个软连接
[root@cms local]# ls #查看
bin games lib mysql sbin src
etc include libexec mysql-5.5.15-linux2.6-i686 share
[root@cms local]# cd mysql
[root@cms mysql]# less INSTALL-BINARY #参照install-binary来配置
[root@cms mysql]# groupadd mysql
[root@cms mysql]# useradd -r -g mysql mysql
[root@cms mysql]# chown -R mysql .
[root@cms mysql]# chgrp -R mysql .
[root@cms mysql]# chown -R root .
[root@cms mysql]# chown -R mysql data
[root@cms mysql]# scripts/mysql_install_db --user=mysql & #初始化数据库
[root@cms mysql]# bin/mysqld_safe --user=mysql & #启动mysql
[root@cms mysql]# vim /etc/profile #修改环境变量
[root@cms mysql]# . /etc/profile #重新读取数据库文件
[root@cms mysql]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin:/usr/local/mysql/bin
[root@cms mysql]# cd support-files/
[root@cms support-files]# cp my-large.cnf /etc/my.cnf
[root@cms support-files]# cp mysql.server /etc/init.d/mysqld
[root@cms support-files]# service mysqld restart #重启服务
Shutting down MySQL..120506 16:05:44 mysqld_safe mysqld from pid file /usr/local/mysql/data/cms.pid ended
[ OK ]
Starting MySQL.. [ OK ]
[1]+ Done bin/mysqld_safe --user=mysql (wd: /usr/local/mysql)
(wd now: /usr/local/mysql/support-files)
[root@cms support-files]# netstat -tupln |grep mysql #查看服务开启端口
tcp 0 0 :::3306 :::* LISTEN 4423/mysqld
[root@cms support-files]# chkconfig mysqld on #设置开机启动
[root@cms support-files]# chkconfig --list |grep mysql
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
对头文件进行连接
[[root@cms support-files]# cd /usr/include
[root@cms include]# ln -s /usr/local/mysql/include mysql
对库文件进行连接
[root@cms include]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf #显示该内容
[root@cms include]# cd /etc/ld.so.conf.d
[root@cms ld.so.conf.d]# vim mysqld.conf
四.安装Apache
[root@cms ld.so.conf.d]# cd
[root@cms ~]# tar -jxvf httpd-2.2.19.tar.bz2 -C /usr/local/src #对该源码进行解压缩
[root@cms ~]# cd /usr/local/src
[root@cms ~]# cd httpd-2.2.19
[root@cms httpd-2.2.19]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-ssl --enable-so --with-z
[root@cms httpd-2.2.19]# make #对源码进行编译
[root@cms httpd-2.2.19]# make install #对源码进行安装
[root@cms httpd-2.2.19]# cd /etc/httpd/
[root@cms httpd]# ll
[root@cms httpd]# vim httpd.conf #修改主配置文档
[root@cms httpd-2.2.19]# cd /usr/local/apache/htdocs
[root@cms htdocs]# vim index.html
[root@cms htdocs]# vim /etc/profile #修改系统的环境变量
[root@cms htdocs]# . /etc/profile #重新读取该文件
[root@cms htdocs]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/mysql/bin:/root/bin:/usr/local/mysql/bin:/usr/local/apache/bin
对库文件进行连接
[root@cms htdocs]# cd /etc/ld.so.conf.d/
[root@cms htdocs]# vim httpd.conf
[root@cms ld.so.conf.d]# apachectl stop
[root@cms ld.so.conf.d]# apachectl start
[root@cms ld.so.conf.d]# netstat -tupln |grep httpd
tcp 0 0 :::80 :::* LISTEN 2862/httpd
测试一下
五.安装PHP
[root@cms ~]# tar -jxvf php-5.3.7.tar.bz2 -C /usr/local/src #对源码进行解压缩
[root@cms ~]# cd /usr/local/src/php-5.3.7 #切换目录
[root@cms 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
[root@cms php-5.3.7]# make #对源码进行编译
[root@cms php-5.3.7]# make test #测试(可省)
[root@cms php-5.3.7]# make install #对源码进行安装
下面是Apache跟PHP的结合
[root@cms php-5.3.7]# vim /etc/httpd/httpd.conf #修改主配置文档
[root@cms php-5.3.7]# cd /usr/local/apache/htdocs/
[root@cms htdocs]# vim index.php
[root@cms php-5.3.7]# cd /usr/local/apache/modules/
[root@cms modules]# ll
[root@cms modules]# apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
httpd (pid 845) already running
在浏览器输入http://192.168.10.20出现下面结果
若输入http://192.168.10.20/index.php则出现下面结果