一般情况下linux默认安装了apache如果安装了我们先把它卸载掉<?xml:namespace prefix="o" ns="urn:schemas-microsoft-com:office:office">?xml:namespace>

rpm-qa|grephttpd检查一下是否安装

rpm-ehttpd-2.2.3-63.el5.centos卸载

error:Faileddependencies:

httpd>=2.2.0isneededby(installed)gnome-user-share-0.10-6.el5.i386说明有依赖关系要先卸载gnome-user-share-0.10-6.el5.i386

rpm-egnome-user-share-0.10-6.el5.i386

mysqlphp也是这么检查和卸载

gcc

编译源码时需要gcc编译器所以要检查是否安装

[root@localhost~]#rpm-qa|grep^gcc

gcc-gfortran-4.1.2-52.el5

gcc-4.1.2-52.el5

gcc-c++-4.1.2-52.el5

可以看出已经安装了gcc

Libxml2安装php5需要libxml2没有安装会出现错误,所以也要提前确认是否安装

[root@localhost~]#rpm-qa|greplibxml2

libxml2-devel-2.6.26-2.1.12.el5_7.2

libxml2-python-2.6.26-2.1.12.el5_7.2

libxml2-2.6.26-2.1.12.el5_7.2

可以看出已经安装

安装apache

开始安装前我们先将下载的源码包全部上传到/目录下的web目录下首先我们创建web目录

cd/

[root@localhost/]#ls

bindevhomelost+foundmiscnetprocsbinsrvtftpbootusr

bootetclibmediamntoptrootselinuxsystmpvar

[root@localhost/]#mkdirweb

[root@localhost/]#ls

bindevhomelost+foundmiscnetprocsbinsrvtftpbootusrweb

bootetclibmediamntoptrootselinuxsystmpvar

我用的是虚拟机安装源码包在u盘所以需要挂载u

[root@localhost/]#fdisk–l

[root@localhost/]#mount/dev/sda1/mnt/

[root@localhost/]#cp/mnt/httpd-2.2.11.tar.bz2web/依次拷入

[root@localhost/]#lsweb/

httpd-2.2.11.tar.bz2mysql-5.0.56.tar.gzphp-5.2.9.tar.bz2

进入web目录解压

[root@localhostweb]#tarjxvfhttpd-2.2.11.tar.bz2

执行完后进入解压目录

[root@localhostweb]#cdhttpd-2.2.11

第一步配置apache

[root@localhosthttpd-2.2.11]#./configure--prefix=/web/apache--enable-so--enable-rewrite--disable-cgid-cgi

这里大略说一下configure指令。--prefix后面的/web/apache是安装目录enable后面模块选项。这里选用一些常用的模块,so是支持动态链接机制上加载apache模块和库。Rewriteapache读写功能

然后执行第二部---编译

[root@localhosthttpd-2.2.11]#make

编译完后最后执行----安装

[root@localhosthttpd-2.2.11]#makeinstall

安装完成后我们先不启动服务,apache安装后并不是作为系统服务去自动启动的;那么我们就手动把它加到系统启动服务里去,让它随着系统的启动而启动。那么我们就需要在系统启动问价加入apache服务,首先用编辑器打开它

[root@localhosthttpd-2.2.11]#vi/etc/rc.d/rc.local

touch/var/lock/subsys/local下一行添加

/web/apache/bin/apachectlstart

添加后保存退出

下面我们使用命令启动一下apache

[root@localhosthttpd-2.2.11]#/web/apache/bin/apachectlstart

然后打开ie看一下

<?xml:namespace prefix="v" ns="urn:schemas-microsoft-com:vml">?xml:namespace>

OK说明apache已经安装成功

安装mysql

回到软件包目录,解压mysql安装包。

cd/web

tarzxvfmysql-5.0.56.tar.gz

进入解压目录

[root@localhostweb]#cdmysql-5.0.56

进入mysql-5.0.56目录后

第一步配置mysql

./configure--prefix=/web/mysql--with-comment=Source--with-server-suffix=-enterprise-gp1--with-mysqld-user=mysql--without-debug--with-socket-path=/myweb/mysql/var/mysql.sock--with-big-tables--with-charset=utf8--with-collcation=utf8_general_ci--with-extra-charsets=all--with-pthread--enable-static--enable-thread-safe-client--with-client-lsflags=-all-static--with-mysqld-ldflags=-all-static--enable-assember--without-innodb--without-ndb-debug--without-isam--enable-local-infile--with-readline--with-raid

这里简单说一下configure指令—prefix是安装目录--with-mysqld-user=mysql是说mysql启动以后所需要的一个用户--with-charset=utf8--with-collcation=utf8_general_ci是说字符集

然后执行第二步---编译

[root@localhostmysql-5.0.56]#make

完成后最后执行安装

[root@localhostmysql-5.0.56]#makeinstall

安装完成后我们需要建立一个支持mysql服务运行的组和账户,此账户无需密码,因为此账户只需要支持mysql在系统中运行即可。

[root@localhost~]#groupaddmysql建立mysql用户组

[root@localhost~]#useradd-gmysqlmysql建立一个mysql用户并且在mysql用户里面

然后进入到安装目录里面

[root@localhost~]#cd/web/mysql执行chown-Rmysql.

意思是改变mysql目录的属性后面一点是代表root/

再执行[root@localhostmysql]#chgrp-Rmysql.同上

接下来我们安装它基本的库(使用的是mysql用户来装的)

[root@localhostmysql]#bin/mysql_install_db--user=mysql

然后再改变用户的相应的属性:

[root@localhostmysql]#chown-Rroot.

然后将属性赋予var

[root@localhostmysql]#chown-Rmysqlvar

复制mysql的配置文件到系统目录/etc目录下并重命名为my.cnf

[root@localhostmysql]#cpshare/mysql/my-medium.cnf/etc/my.cnf

我们把mysql的服务拷贝到系统服务中去

[root@localhostmysql]#cpshare/mysql/mysql.server/etc/rc.d/init.d/mysqld

然后改变mysql启动文件的权限

[root@localhostmysql]#chmod755/etc/rc.d/init.d/mysqld

加载上mysql文件

[root@localhostmysql]#chkconfig--addmysqld

改变mysql的启动级别

[root@localhostmysql]#chkconfig--level3mysqldon

启动mysql

[root@localhostmysql]#servicemysqldstart

已经启动,安装完后我们的数据库密码是空的那么我们就需要改掉mysqlROOT的密码

[root@localhostmysql]#bin/mysqladmin-urootpassword123456

到此mysql数据库完全安装成功!

安装php

解压php

[root@localhostweb]#tarjxvfphp-5.2.9.tar.bz2

进入到解压目录

[root@localhostweb]#cdphp-5.2.9

第一步配置php

[root@localhostphp-5.2.9]#./configure--prefix=/web/php--with-apxs2=/web/apache/bin/apxs--with-zlib-dir--with-bz2--with-libxml-dir--enable-mbstring--with-mysql=/web/mysql--with-config-file-path=/etc--with-iconv--disable-ipv6--enable-static--enable-sockets--enable-soap--with-openssl--with-gettext--enable-ftp

make

makeinstall

安装后我们将php安装目录下php.ini-recommended拷贝到/etc目录下并重命名为php.ini

cpphp.ini-recommended/etc/php.ini

到此php安装结束

整合apachephp

vi/web/apache/conf/httpd.conf

找到

LoadModulephp5_modulemodules/libphp5.so

如果没有那么说明安装的phpsever没有加载php的模块,那么就是你安装php的时候安装有问题。

找到

DocumentRoot"/web/www"

把它变成自己的目录,共两处都要改为一致。

第二处如下图

找到DirectoryIndexindex.html修改为DirectoryIndexindex.htmlindex.php

找到OptionsIndexesFollowSymLinks然后注释掉#OptionsIndexesFollowSymLinks意思是不想让别人找到你网站根目录有哪些文件目录那么就注释掉它对网站来说更安全)

找到AllowOverrideNone改为AllowOverrideall意思是说是否允许apache具有重写功能!这里我们设置为开启apache的重写功能如下图:

找到AddTypeapplication/x-compress.Z

AddTypeapplication/x-gzip.gz.tgz

在下面加上

AddTypeapplication/x-httpd-php.php让它能解释php的文件,保存后退出。

我们在web目录下建立一个www的文件夹存放我们的网站网页

mkdir/web/www

最后在/web/www目录下编写一个简单的php测试网页看一下php的环境是否配置成功

#vi/web/www/index.php

写入以下内容:

<?php

Phpinfo();

?>

保存退出!

setenforce0关闭一下selinux不需重启或者修改/etc/selinux/config文件中设置SELINUX=disabled需重启生效

iptables–F关闭一下防火墙

#/web/apache/bin/apachectlrestart重启一下apache

打开网页看一下