当前位置: 首页 > 图文教程 > 操作系统 > Unix/Linux > RedHat Enterprise Linux 5下配置Apache+Mysql+Php

Unix/Linux
mysql+httpd+gd+php+zend
automake 小回顾
unix黑客精神的最好诠释
www
sun t3存储的设置
RPM简明中文手册
Linux爱好者入门教程 序章 (持续更新)
第一章 Linux基础知识 (飘心)
linux下进程与线程
浅谈如何学习linux
第二章 Linux安装
硬件安装指南
Windows 2000 的桌面不見了的解決方法
部分的ADSL路由器默认帐号密码
如何设定安全log服务器呢?
iptables 规则速查
网友学习 Linux 的七点忠告
sniffer的含义及原理
Linux编程白皮书 第二章 内存管理
Linux编程白皮书 第二章 内存管理 2.1.1 请求调页 --2.1.5 访问控制

Unix/Linux 中的 RedHat Enterprise Linux 5下配置Apache+Mysql+Php


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-15   浏览: 221 ::
收藏到网摘: n/a

第一步:系统与软件的准备
系统版本 redhat enterprise linux 5 ,内核版本 2.6.18
系统安装组件选择:GNOME,图形化互联网,编辑器,开发工具,基本系统系统工具,管理工具,X窗口环境
(因为机器有限,要从本机测试,所以安装GNOME和互联网环境)
第二步:软件包的准备
httpd软件包:httpd-2.2.8.tar.bz2
mysql软件包从mysql官方网站下载,我选用的是ehel5的rpm包
MySQL-server-community-5.0.51a-0.rhel5.i386.rpm
MySQL-client-community-5.0.51a-0.rhel5.i386.rpm
MySQL-devel-community-5.0.51a-0.rhel5.i386.rpm
MySQL-shared-community-5.0.51a-0.rhel5.i386.rpm
php5软件包:php-5.2.5.tar.bz2
其他库文件:
curl-7.15.0.tar.gz
freetype-2.3.5.tar.gz
gd-2.0.35.tar.gz
jpegsrc.v6b.tar.gz
libpng-1.2.26.tar.gz
libxml2-2.6.31.tar.gz
PDFlib-7.0.3-Linux-php.tar.gz
t1lib-5.0.0.tar.gz
xpm-3.4k.tar.gz
zlib-1.2.3.tar.gz
gettext-0.16.tar.gz
其他管理软件包:
phpMyAdmin-2.11.6-rc1-all-languages.tar.gz
webmin-1.410.tar.gz
第三步开始安装安装的顺序,httpd和mysql的安装,从这个环境而言是无所谓的,只是php5软件包要最后安装,先安装httpd
简要步骤如下,#号提示符后面为命令,复制所有软件包到一个位置,我这里是在/usr/local/src目录下创建lamp目录,然后复制所有软件包到lamp下
#cd /usr/local/src/lamp
#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://你的服务器ip地址,记得开放服务器的80端口,不然可能会提示错误,如果正确的话会出现一个"It works !"的提示页面,此时,apache2基本安装完成。
接下来进行Mysql的安装,我先安装mysql-server的安装包,提示需要perl-DBI包,从安装光盘上即可找到,DVD安装的直接就去光盘上的Server文件夹去找就可以了,如果是cd安装,就去cd-2上去同样的目录。
#mount /dev/cdrw /media
#rpm -ivh /media/Server/perl-DBI-1.52-1.fc6.i386.rpm
安装完成后再依次安装mysql的其他包
#rpm -Uvh MySQL-server-community-5.0.51a-0.rhel5.i386.rpm
#rpm -Uvh MySQL-client-community-5.0.51a-0.rhel5.i386.rpm
#rpm -Uvh MySQL-devel-community-5.0.51a-0.rhel5.i386.rpm
#rpm -Uvh MySQL-shared-community-5.0.51a-0.rhel5.i386.rpm
安装完成后修改mysql的root用户密码,默认为空,修改命令如下
#/usr/bin/mysqladmin -u root password '密码字符串'
以后再从命令行登录mysql的就输入
#mysql -u root -p
会提示输入密码,Mysql的基本安装完成。
接下来是其他库文件的安装,这些软件包的安装顺序应该可以自由选择(zlib在libpng前安装),不过我认为可以先把Zlib安装上,仅作参考。
我这次的顺序就没有先安装zlib,就随便选择来安装了,先是Curl,
#tar zxvf curl-7.15.0.tar.gz
#cd curl-7.15.0
#./configure --prefix=/usr/local/curl
(我认为可以加上--with-zlib开关,只是这次我没有用)
#make
#make install
jpeg的安装,jpeg不能自己创建安装所需的目录,要提前创建好
#mkdir -pv /usr/local/jpeg/{,bin,lib,include,man/man1,man1}
#./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
#make
#make install
libxml2的安装
#tar zxvf libxml2-2.6.31.tar.gz
#cd libxml2
#./configure --prefix=/usr/local/libxml2
(可以尝试打开zlib开关,--with-zlib)
#make(时间可能稍微长些)
#make install
#cp xml2-config /usr/bin
LibPDF的安装
#tar zxvf PDFlib-7.0.3-Linux-php.tar.gz
#cd pdflib
#cp bind/php5/php520mt/libpdf-php.so /usr/local/lib/
(上面的php520mt目录的同级目录中有php503,php510,php520目录,不知道是不是版本的区别)
T1lib的安装
#tar zxvf t1lib-5.0.0.tar.gz
#cd t1lib
#./configure --prefix=/usr/local/t1lib
#make without-doc
#make install
Freetype的安装
#tar zxvf freetype-2.3.5.tar.gz
#cd freetype
#./configure --prefix=/usr/local/freetype
#make
#make install
Zlib的安装
#tar zxvf zlib-1.2.3.tar.gz
#./configure --shared
#make
#make install
Libpng的安装
#tar zxvf libpng-1.2.26.tar.gz
#cd libpng
#cp scripts/makefile.linux ./makefile
#./configure --prefix=/usr/local/libpng
#make
#make install
GDlib的安装,可能会出现 AM_ICON 的错误提示,此时需要安装 gettext 软件包
#tar zxvf gettext-0.16.tar.gz
#cd gettext
#./configure --prefix=/usr/local/gettext
#make
#make install(时间稍长)
接下来是gdlib的安装
#tar zxvf gd-2.0.35.tar.gz
#cd gd
#./configure --with-png=/usr/local/lib \
--with-zlib=/usr/local/lib \
--with-freetype=/usr/local/freetype/lib \
--with-jpeg=/usr/local/jpeg/lib
#make
#make install
PHP5的安装
#tar zxvf php-5.2.5.tar.bz2
#cd php
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs \
--enable-track-vars --with-sockets --enable-sockets --with-sysvshm --with-sysvsem \
--with-pdflib-dir=/usr/local/lib --with-jpeg-dir=/usr/local/jpeg \
--with-png-dir=/usr/local/lib --with-zlib-dir=/usr/local/lib \
--with-freetype-dir=/usr/local/freetype --with-curl=/usr/local/curl \
--with-libxml-dir=/usr/locallibxml2/lib --with-t1lib=/usr/localt1lib \
--with-gettext=/usr/localgettext/lib --with-gd --with-mysql
(最好加上mbstring 和 mcypt ,不知道是不是必须)
configure后如果成功会提示PHP欢迎界面: Thank you for using PHP.
#make
#make test
(大约3000多项测试吧)
# make install
Php.ini文件的修改
#cp php.ini.dist /usr/local/lib/
查找修改extension_dir='./'的内容
extension_dir = /usr/local/lib
extension=libpdf_php.so
保存退出

最后修改apache配置文件httpd.conf
#vi /usr/local/apache2/conf/httpd.conf
查找AddType 大约在DefaultType text/plain

输入如下内容
AddType application/x-httpd-php .htm
AddType application/x-httpd-php .html
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
AddType application/x-httpd-php-source .phps
(不清楚是不是必须输入这么多项)
查找DirectoryIndex index.html 在其后输入 index.php
保存文件,退出。
测试php,创建info.php文件放到网站的目录下,我这里是/usr/local/apapche2/htdocs
内容如下