linux下amp的架设〈来自chinaunix〉

由于gd2才开始支持真彩图片的创建,所以,,升级服务器,因为原来的安装都是默认的系统安装,
也更因为是个菜鸟,所以,安装很困难,起初根据网上一些文章在我的red hat A 3 上安装测试,
不过,测试了安装php4.3.X 和php5.0.X都没有成功,最后,根据其他人的文章,
自己搞了将近3天,终于安装上了,下面就我安装中出现的错误和过程写出来和大家分享,
以免有像我一样的菜鸟们走弯路! (我可是两天多的时间,安装php的次数不下50次得来的经验,
希望大家多多支持,有错误当然欢迎给我指正!
转载请注明来自中国智慧在线(http: //article.21e.cn ,谢谢!),
以下经过测试在red hat 9 和red hat A 3上通过! 
欢迎转载,但是请注明原出处:http://article.21e.cn  !!谢谢! 

说明:本次升级涉及所有文件均存放在/backup/tools/webserver目录下,当然你也可以按照文章的提示
自行下载。rpm文件下载查找地址:rpmfind.net,它同时提供相关rpm包的官方连接。
  

如果你机器里原来装有了PHP或者APACHE的RPM或者低版本.你可以现删除,删除安装简洁一些,不过我的实际操作过程是煤油删除,而直接安装的.当然你也可以跟我一样! 
首先,服务器GCC要有,不然什么都不能做.可以用gcc -v来查看是否安装了GCC, 
#gcc -v 
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs 
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux 
Thread model: posix 
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-34) 

有以上类似信息说明已有GCC, 
没有就现安装吧,至于如何安装,我就不说了,可以用光盘安装或者是下载源文件都可以,当然你的版本不一定是3.2.3! 

请下载以下所有的东西: 
httpd-2.0.X.tar.gz 版本最好是下载最新的啦,下载地址:http://www.apache.org 

php-4.3.X.tar.gz 下载地址:http://www.php.net,本机已经存放在/backup/tools/webserver目录下   
ZendOptimizer-2.5.3-linux-glibc21-i386.tar.gz 
   zend的最新版安装是好像有点问题,就下载这个版本就可以,zend用来加速php,你可以选择不安装!下载地址:http: //www.zend.com 
gd-2.0.28.tar.gz 这个软件的下载地址,php推荐的是:http://www.boutell.com/gd/  但是由于某些原因,开发者不支持gif图像的创建,这有点不太方便,所以,我下载了个支持gif图像的,也就是打了gif补丁的:http: //www.rime.com.au/gd/ 
libxml2-2.X.X.tar.gz  下载地址: 
zlib-1.X.X.tar.gz 忘记了,自己找一下吧 
jpegsrc.v6b.tar.gz 下载地址:ftp://ftp.uu.net/graphics/jpeg/ 
libpng-1.2.5.tar.gz 下载地址:http://www.libpng.org/pub/png/libpng.html 
freetype2-X.X.tar.gz 下载地址:http://www.fretype.org 

xpm-3.4k-2.i386.rpm 下载地址:http://www.rpmfind.net

以上都是我下载的官方地址,软件的版本中的X,你自己看看你想用哪个版,不过最好是用最新稳定版本的!如果你以前安装过上述软件的其他版本,你也可以选择不安装! 



安装XPM 

#rpm -ivhxpm-3.4k-2.i386.rpm 

安装libxml 
# tar -zxf libxml2-2.6.16.tar.gz 
# cd libxml2-2.6.16 
# ./configure (xml默认安装就可以,不要指定路径了,因为安装时php可能找不到它,PHP5只支持libxml2-2.5.10以上版本) 
# make  
# make install 

安装zlib 
# tar -zxf zlib-1.2.2.tar.gz  
# cd zlib-1.2  
# ./configure --prefix=/usr/local/zlib2 (注意,如果您以前没有安装zlib,可以不指定路径,我是没有删除以前的低版本才指定的!以下雷同!) 
# make  
# make install  

安装jpeg
如果采用rpm包安装,rpm -ivh --force jpeg.v6b.rpm  --prefix=/usr/local/jpeg2
采用源码configure.用下面的命令。
# tar -zxf jpegsrc.v6b.tar.gz  
# cd jpeg-6b/ 
# ./configure --prefix=/usr/local/jpeg6   
# make  
# make install-lib  
如果你选择默认安装,可能很顺利,指定路径后,请先创建以下文件夹 
错误提示:...... /usr/bin/install -c -m 644 jconfig.h /usr/local/jpeg6/include/jconfig.h 
/usr/bin/install: 无法创建一般文件‘/usr/local/jpeg6/include/jconfig.h’: 没有那个文件或目录 
make: *** [install-headers] Error 1 
# mkdir /usr/local/jpeg6  
# mkdir /usr/local/jpeg6/include  
# mkdir /usr/local/jpeg6/lib 
# make install-lib  
# make install  

安装时如果错误提示: 
/usr/bin/install: 无法创建一般文件‘/usr/local/jpeg6/lib/libjpeg.a’: 没有那个文件或目录 
make: *** [install-lib] Error 1 
创建如下文件夹: 
# mkdir /usr/local/jpeg6/lib 
# make install 
/usr/bin/install -c cjpeg /usr/local/jpeg6/bin/cjpeg 
/usr/bin/install: 无法创建一般文件‘/usr/local/jpeg6/bin/cjpeg’: 没有那个文件或目录 
make: *** [install] Error 1 
# mkdir /usr/local/jpeg6/bin 
/usr/bin/install -c -m 644 ./cjpeg.1 /usr/local/jpeg6/man/man1/cjpeg.1 
/usr/bin/install: 无法创建一般文件‘/usr/local/jpeg6/man/man1/cjpeg.1’: 没有那个文件或目录 
make: *** [install] Error 1 
# mkdir /usr/local/jpeg6/man 
# mkdir /usr/local/jpeg6/man/man1 
# make install  
好了,直到安装成功! 

安装libpng: 
# tar -zxf libpng-1.2.7-config.tar.gz  
# cd libpng-1.2.7-config  
# ./configure --prefix=/usr/local/libpng2  
# make  
# make install  

安装freetype: 
# tar -zxf freetype-2.1.9.tar.gz  
# cd freetype-2.1.9  
# ./configure --prefix=/usr/local/freetype2  
# make  
# make install 

安装gd库: 
# tar -zxf gd-2.0.26gif.tar.gz 
# cd gd-2.0.26gif   
# ./configure --prefix=/usr/local/gd2 --with-zlib=/usr/local/zlib2/ --with-png=/usr/local/libpng2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype2/ (请指定及格插件的安装路径,否则安装php的时候可能出错!) 
# make  
# make install  

安装apache,(php5安装环境需要apache2.0.46以上版本,下载的时候注意!) 
#tar zxvf httpd-2.0.54.tar.gz 
#cd httpd-2.0.50 
#./configure --prefix=/usr/local/apache2 --enable-module=so 
#make 
#make install 

安装php4:
这里的configure我已经写成脚本
shell脚本说明: 换行 用反斜杠 \
如果你要修改configure参数,你可以在这个文件里修改。千万注意格式。如果换行一定要用反斜杠

configure脚本位于 /backup/tools/webdocs/myinstall_php.sh

将这个文件拷贝到php4所在的目录下。
# tar -zxf php4-xxxx.tar.gz  
# cd php4-xxxx
# cp /backup/tools/webdocs/myinstall_php.sh ./
# ./myinstall_php.sh
到这里如果万事ok,接着来,如果提示哪里不对,就去纠正,比如,缺某个包,就去装。
# make
我configure的时候加了--with-expat-dir 和 --with-xml参数,结果make死活都过不去,这个参数是用来解析xml文档的。  
# make install  
# cp php.ini-dist /usr/local/php/lib/php.ini 

安装libxml的时候如果指定了路径,make的时候可能出错,所以,我安装的时候没指定! 
我MAKE PHP4.3.8 和5的时候都遇到: 
ext/gd/gd.lo(.text+0x63a): In function `zm_deactivate_gd': 

/root/software/php-4.3.8/ext/gd/gd.c:385: undefined reference to `gdFreeFontCache' 

collect2: ld returned 1 exit status 

make: *** [sapi/cli/php]Error 1 
另外还有一个错误可能是什么: libphp.lo的错误(错误当时没有纪录,忘记了,大概是!) 
是因为GD库的freetype没装,或者是安装gd库的时候煤油指定插件的路径!! 

复制PHP.INI文件到正确位置 
在PHP目录下运行 
#cp php.ini-dist /usr/local/php/lib/php.ini 

编辑apache配置文件httpd.conf 
#vi /usr/local/apache2/conf/httpd.conf 

要改的有如下几处: 

一般都在 
#AddType application/x-tar .tgz 
下加一行 
#LoadModule php5_module modules/libphp5.so 
AddType application/x-httpd-php .php 
如果你搜索其它地方没有以下这行 

LoadModule php4_module modules/libphp4.so 
请把上面的#号去掉 

还有找到 
DirectoryIndex index.html index.html.var  
在后面加 index.php 让它把index.php做为默认页 

找到 
# don't use Group #-1 on these systems! 
把下面的用户名和组改为 
User apache 
Group apache 
(原来好像是nobody) 

再找 
#ServerName  
把#去掉,后面的IP改成你的IP. 

找到 
DocumentRoot "/usr/local/apache2/htdocs" 
把/usr/local/apache2/htdocs改为你存放网页文件的路径 

为了让中文网页没乱码 
找到 
AddDefaultCharset iso8859-1 
把后面的iso8859-1改为gb2312 或者是干脆off 
其他的选项就自己修改吧!或者到http://article.21e.cn  有一个专门的httpd.conf的说明! 

保存httpd.conf文件. 

启动apache 
# /usr/local/apache2/bin/apachectl start  
如果没有出错,写一个测试页放到你网页目录下.访问就应该可以看到php的版本等信息了! 

如无意外.PHP脚本已经可以连接mysql了. 

用ZendOptimizer加速PHP 

#tar zxvf ZendOptimizer-2.5.3-linux-glibc21-i386.tar.gz 
#cd ZendOptimizer-2.5.3-linux-glibc21-i386 
#./install.sh 
安装的时候注意输入正确的安装apache的路径等内容! 
安装完毕,再看看phpinfo页面的zend选项就发现了!! 

如果你以前的apache没有删除,而你又想使用 
# /etc/init.d/httpd restart  
这样重起apache的话,那就修改/etc/init.d/httpd这个文件,修改其中的apahce的三个路径就可以了!! 

在文件/etc/init.d/httpd中找这个地方

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/sbin/apachectl
httpd=${HTTPD-/usr/local/apache2/bin/httpd}
prog=httpd
RETVAL=0

将上面的/usr/local/apache2/bin/httpd 改为当前apache所在的路径。

好了,终于安装完毕,你的机器已经是最新的apache+php+mysql+gd.......了,恭喜!! 

艾,累死我了,整整弄了好几天!!休息了!!~(安装的时候,可能安装的时候和写不不是很一样,不过大同小异!) 


同时感谢以前那几位辛苦的安装者,参照你们的文章我才得以顺利安装成功,虽然还是用了好几天!~:P

 
 

--------------------------------------------------------------------------------
 david5337 回复于:2004-11-28 13:23:55 
支持哦! 
不想玩儿这个东西!

 

--------------------------------------------------------------------------------
 jzz_zh 回复于:2004-11-28 16:07:48 
楼主 的精神可嘉 
安装linux的开源软件,还是要多看看软件自身的ReadMe的好 

支持一下!!

 

--------------------------------------------------------------------------------
附录:php 的 configure 脚本

'./configure' '--host=i386-redhat-linux' '--build=i386-redhat-linux' '--target=i386-redhat-linux-gnu' '--program-prefix=' \
'--prefix=/usr/local/php4b' \
'--with-apxs2=/usr/local/apache2/bin/apxs' \
'--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' \
'--with-config-file-path=/etc/php4b' \
'--with-config-file-scan-dir=/etc/php.d' \
'--enable-force-cgi-redirect' '--disable-debug' '--enable-pic' \
'--disable-rpath' '--enable-inline-optimization' \
'--with-db4=/usr' '--with-curl' '--with-exec-dir=/usr/bin' \
'--with-freetype-dir=/usr/local/freetype2/' \
'--with-png-dir=/usr/local/libpng2/' \
'--with-gd=/usr/local/gd2/' '--enable-gd-native-ttf' \
'--with-gdbm' '--with-gettext' '--with-ncurses' '--with-gmp' '--with-iconv' \
'--with-jpeg-dir=/usr' '--with-openssl' \
'--with-png-dir=/usr/local/libpng2/' \
'--with-zlib-dir=/usr/local/zlib2/' \
'--with-regex=system' \
'--with-dom=/usr/local/libxml2' \
'--with-dom-xslt=/usr/local/libxslt2' \
'--with-dom-exslt=/usr/local/libxslt2' \
'--with-xmlrpc=shared' '--with-pcre=/usr' \
'--with-layout=GNU' '--enable-bcmath' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-discard-path' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--without-oci8' '--with-pear=/usr/share/pear'  '--with-kerberos' '--with-ldap=shared' '--with-mysql' '--enable-memory-limit' '--enable-bcmath' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--enable-mcal' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' \	
-------------------------------------------------------------------------------- day-dreamer 回复于:2004-11-30 14:06:34 我安装XPM时出现以下问题,请各位回答一下,谢谢 #rpm -ivh xpm-3.4k-2.i386.rpm preparing... ################[100%] file /usr/x11R6/lib/libxpm.so.4.11from install of xpm-3.4k-2 conflicts with file from package XFree86-libs-4.3.0.2  为什么与这个XFree86-libs-4.3.0.2冲突呀,请问要怎么解决呀    -------------------------------------------------------------------------------- hutuworm 回复于:2004-11-30 14:37:40 rpm -ivh xpm-3.4k-2.i386.rpm --force -------------------------------------------------------------------------------- day-dreamer 回复于:2004-11-30 14:44:33 谢谢hutuworm,已经可以了. -------------------------------------------------------------------------------- day-dreamer 回复于:2004-11-30 14:55:03 还有以下问题 #tar -zxf gd-2.0.26gif.tar.gz #cd ga-2.0.26gif #./configure --prefix=/usr/local/gd2 --with-zlib=/usr/local/zlib2/ --with-png=/usr/local/libpng2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype2/ 到最后时 configuration summary for gd 2.0.26 support for PNG library : yes support for JPEG library: no support for Freetype 2.x library:yes support for Xpm library : no support for pthreads: yes 以上信息是不是表示不支持JPEG 和 Xpm呀?但是我都已经装了jpegsrc.v6b.tar.gz 和xpm了,请问这个问题怎么处理呢 -------------------------------------------------------------------------------- xuanxuanmylove 回复于:2004-11-30 15:06:31 顶 -------------------------------------------------------------------------------- ecto 回复于:2004-12-01 19:57:03 to:day-dreamer 你安装jpeg的时候指定安装路径了吗? 也就是说你确定你的jpeg是安装到了: usr/local/jpeg6/ 下吗? 如果不是,安装jpeg的时候指定一下就可以了! -------------------------------------------------------------------------------- yudi2006 回复于:2004-12-01 20:06:57 我很菜啊 我还看不懂得啦 -------------------------------------------------------------------------------- peng 回复于:2004-12-01 22:16:40 就是要设置环境变量,让系统知道从那里找到它。。 -------------------------------------------------------------------------------- livid 回复于:2004-12-01 23:46:06 有必要这么累吗?干嘛不用 Debian? -------------------------------------------------------------------------------- cbwcbj 回复于:2005-03-22 12:50:08 我按照楼主的方法安装下去,成功了,我已经确定安装了jpeg,但jpeg不行 在有需要用到图片显示是系统提示:Fatal error: Call to undefined function Imagejpeg() 还要在 apache里打开jpeg功能吗? -------------------------------------------------------------------------------- zhaodahe 回复于:2005-03-23 13:07:34 good
Posted on 2005-08-20 19:15  古代  阅读(777)  评论(0)    收藏  举报