CentOS5.5 下搭建 PHP 环境(最佳的LAMP环境)(2)

2、搭建 LAMP 环境(请按照下面给出的顺序进行安装)

这里所有的软件都安装在 /usr/local 下

一、安装libxml

安装顺序:1、进入 libxml 目录;2、配置参数(包括安装路径;依赖软件;安装功能等);3、编译;4、安装。注:所有软件包安装类似

[root@ lamp]# cd libxml2-2.6.30/ 

[root@ libxml2-2.6.30]# ./configure --prefix=/usr/local/libxml2

./configure 为软件包配置参数命令,--prefix 表示指定的安装目录,大部分目录若不在会自动创建,个别不会,需要我们手动创建

[root@ libxml2-2.6.30]# make && make install 

以上命令是将编译和安装在一起执行,由于软件小,安装速度比较快,若大的软件,可能会花比较长的时间。

二、安装libmcrypt

[root@ lamp]# cd libmcrypt-2.5.8/ 

[root@ libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt 

[root@ libmcrypt-2.5.8]# make && make install

三、安装zlib

[root@ lamp]# cd zlib-1.2.3/ 

[root@ zlib-1.2.3]# ./configure 

[root@ zlib-1.2.3]# make && make install 

./configure 后面不要跟 --prefix 参数,让其安装在默认目录中,因为安装 libpng 的时候会用到 zlib。

四、安装libpng

[root@ lamp]# cd libpng-1.2.31/ 

[root@ libpng-1.2.31]# ./configure --prefix=/usr/local/libpng 

[root@ libpng-1.2.31]# make && make install

五、安装jpeg6

这个软件配置的时候不会自动创建目录,需要我们手动创建

[root@ libpng-1.2.31]# mkdir /usr/local/jpeg6 

[root@ libpng-1.2.31]# mkdir /usr/local/jpeg6/bin 

[root@ libpng-1.2.31]# mkdir /usr/local/jpeg6/lib 

[root@ libpng-1.2.31]# mkdir /usr/local/jpeg6/include 

[root@ libpng-1.2.31]# mkdir -p  /usr/local/jpeg6/man/man1 

生成目录完毕!

[root@ lamp]# cd jpeg-6b/ 

[root@ jpeg-6b]# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static 

[root@ jpeg-6b]# make && make install

./configure 中参数说明:

--enable-shared  建立共享库使用的GNU的libtool

--enable-static  建立静态库使用的GNU的libtool

六、安装freetype

[root@ lamp]# cd freetype-2.3.5/ 

[root@ freetype-2.3.5]# ./configure --prefix=/usr/local/freetype 

[root@ freetype-2.3.5]# make && make install

七、安装autoconf

[root@ lamp]# cd autoconf-2.61/ 

[root@ autoconf-2.61]# ./configure 

[root@ autoconf-2.61]# make && make install

这个软件直接安装在默认目录下。

八、安装GD

[root@ lamp]# cd gd-2.0.35/ 

[root@ gd-2.0.35]# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype/ 

[root@ gd-2.0.35]# make && make install

./configure 中参数说明:

--with-jpeg=/usr/local/jpeg6/ 指定到哪去找jpeg库文件的位置

--with-png=/usr/local/libpng/ 指定到哪去找png库文件的位置

--with-freetype=/usr/local/freetype/ 指定到哪去找freetype 2.x字体库的位置

注意 安装此软件包可能会出现以下错误,如下图所示:

CentOS5.5 下搭建 PHP 环境(最佳的<a href=LAMP环境)" src="https://www.linuxidc.com/upload/2012_12/121206163738651.png" />

如果出现如此错误,解决方法:

[root@ gd-2.0.35]# vi gd_png.c 

找到关键词"png.h" 命令:/png.h 回车

替换为:/usr/local/libpng/include/png.h

效果如下图所示:

保存退出,继续执行"make && make install" 执行即可安装成功。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/061c35e0c85342c28abf46edd896e5d4.html