RedHat Enterprise Linux 5配置Mysql+Apache+Php


第一步:系统与软件的准备

系统版本 redhat enterprise linux v5.3 ,内核版本 2.6.18

第二步:软件包的准备

Apache2软件包:httpd-2.2.13.tar.gz

php5软件包:php-5.3.0.tar.gz

第三步, 架设YUM仓库

由于系统连GCC都没有给我们安装,因此是无法直接去make安装上述源代码的,必须先使用系统光盘架设一个YUM代码仓库,从中安装我们所需要的各种软件。

首先,我们按照系统安装光盘上所有的文件拷贝一份到RHEL5中(假设放置目录为/home/phinecos/back)

然后,我们要先安装一个RPM包才能开始架设YUM仓库

# cd /home/phinecos/back/Server
# rpm -ihv createrepo-0.4.4-2.fc6.noarch.rpm

这个包安装之后,会生成一个新的命令:/usr/bin/createrepo,而这个命令是我下面必须要用到的。

RHEL5 所有的 Package 主要位于 Server, VT, Cluster, ClusterStorage 等目录, 该目录内有 repodata/ 目录放置 yum 程序所需要的索引信息档案, 包含 GUI 的套件新增移除所需要的大项分类信息. 不过由于该档案预设提供的是 cd disc 的方式安装使用, 所以需要手动建立新的档案提供 yum 与 GUI Packager 正常运作使用.

首先先复制出来 Server, VT, Cluster, ClusterStorage 目录内位于 repodata/ 内 comps-rhel5-*.xml 档案到暂存目录内提供后续要使用, 然后删除 repodata 目录, 重新建立新的 repodata 目录结构与必要索引档案.

cd /home/phinecos/back
for name in Server VT Cluster ClusterStorage
do
cp $name/repodata/comps-rhel5-*.xml /tmp
done

# Server
cd /home/phinecos/back/Server
rm -rf repodata
createrepo -g /tmp/comps-rhel5-server-core.xml .

# VT
cd /home/phinecos/back/VT
rm -rf repodata
createrepo -g /tmp/comps-rhel5-vt.xml .

# Cluster
cd /home/phinecos/back/Cluster
rm -rf repodata
createrepo -g /tmp/comps-rhel5-cluster.xml .

# ClusterStorage
cd /home/phinecos/back/ClusterStorage
rm -rf repodata
createrepo -g /tmp/comps-rhel5-cluster-st.xml .

我们的YUM仓库到这里也就建好了。接下来,我们要做的就是要设置/etc/yum.repo.d里面的内容了,首先创建一个rhel-server.repo文件,在其中写入下述内容:

[Server]
name=Red Hat Enterprise Linux Server Core
baseurl=file:///home/phinecos/back/Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[VT]
name=Red Hat Enterprise Linux Virtual Technology
baseurl=file:///home/phinecos/back/VT
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[Cluster]
name=Red Hat Enterprise Linux Cluster
baseurl=file:///home/phinecos/back/Cluster
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[ClusterStorage]
name=Red Hat Enterprise Linux Cluster Storage
baseurl=file:///home/phinecos/back/ClusterStorage
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

当然,你也可以通过http与ftp方式把这个目录发布出去,那只要把相关的file:/// home/phinecos/back/这部分修改一下就可以了。

第四步,安装图形化互联网,开发工具等必须的软件

“Applications”à”Add/Remove Software”里面安装所需的基本工具软件,如gcc等。

第五步,安装Apache2

#tar zxvf httpd-2.2.8.tar.bz2
#cd http-2.2.8
#./configure --prefix=/usr/local/apache2 --enable-rule=SHARED_CORE --enable-module=so
#make
#make install

安装apache完成,输入命令

#/usr/local/apache2/bin/apachectl -k start
从本地或其它机器打开Firefox浏览器,输入地址http://127.0.0.1,如果正确的话会出现一个"It works !"的提示页面,此时,apache2基本安装完成。

第五步,安装MySQL

“Applications”à”Add/Remove Software”里面找到MySql,进行安装,如果安装后发现启动mysql时出现:

Starting MySQL..[FAILED]
这是SELINUX在作怪,解决办法:

进/etc/selinux 然后vi config 把SELINUX=enforcing 这一行
改为:SELINUX=disabled

然后保存,电脑重启,然后再把以前装的MYSQL删除重装下

启动mysql

/etc/init.d/mysql start 或 service mysql start
停止mysql

/etc/init.d/mysql stop 或 service mysql stop

相关内容