httpd+xpm+libxml+jpegsrc+libpng+freetype+zlib+gd+php-5.2.2+ZendOptimizer-3.0.1+Mysql

来源:互联网 发布:战神诀披风进阶数据 编辑:程序博客网 时间:2024/05/22 12:41
http://xiahongyuan.blog.51cto.com/906214/871066

一点小常识:重新启动mysql,命令:#/etc/init.d/mysqld restart
         重新启动apache,命令:# /etc/init.d/httpd restart
-------------------------------------------
# unrar e all.rar
这条命令是将all.rar中的所有文件解压出来
另外一种方法:对于.tar结尾的文件#tar -xf all 同样可以
-------------------------------------------
注意:在这里我的Mysql是安装的光盘自带的,若是从网上下载也是很容易安装的,不复赘述。
        这个环境搭建完之后,你几乎可以为所欲为,其中我将我的错误也写在其中希望能对您有所帮助。
---------------------------------天匆云汇
1.安装apache,(php5安装环境需要apache2.0.46以上版本,下载的时候注意!)
#tar zxvf httpd-2.0.59.tar.gz    (此为较新版本)
#cd httpd-2.0.59
#./configure --prefix=/usr/local/apache2 --enable-module=so
#make
#make install

2.安装xpm-3.4k.tar.gz

#tar -zxf xpm-3.4k.tar.gz
#xmkmf -a
如果上一句不行则执行:
                xmkmf
                make Makefiles
                make includes
                make depend

接下来执行:
#make
which will build the XPM library and the sxpm application. Then do:
                make install
                make install.man

which will install the library and the sxpm program and man page.

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

4.安装jpegsrc.v6b.tar.gz
# 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
好了,直到安装成功!

5.安装libpng-1.2.18.tar.gz:(2007-05-15 17:04新版本)
# tar -zxf libpng-1.2.18.tar.gz
# cd libpng-1.2.18
# ./configure --prefix=/usr/local/libpng2
# make
# make install

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

6.5.安装zlib-1.2.3.tar.gz
# tar -zxf zlib-1.2.3.tar.gz
# ./configure --prefix=/usr/local/zlib2
# make
# make install

7.安装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的时候可能出错!我的就没有安装,呵呵,所以我把--with-zlib=/usr/local/zlib2/给去掉了!)
# make
# make install

8.安装php5:
# tar -xjf php-5.2.2.tar.bz2
# cd php-5.2.2
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng2/ --with-gd=/usr/local/gd2/ --with-freetype-dir=/usr/local/freetype2/ --enable-trace-vars --with-zlib-dir=/usr/local/zlib2/ -with-mysql=/var/lib/mysql
# make
# 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 php5_module modules/libphp5.so
请把上面的#号去掉

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

找到
# don't use Group #-1 on these systems!
把下面的用户名和组改为
User apache
Group apache
(原来好像是nobody,这里我的改为了root因为自己用。要是用来作服务一定按上面的做)

再找
#ServerName
把#去掉,后面的IP改成你的IP.
我的改为了:localhost

找到
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的版本等信息了!

我的出现了两种错误,错误信息如下:
1.
[root@localhost ~]# /usr/local/apache2/bin/apachectl start
Syntax error on line 268 of /usr/local/apache2/conf/httpd.conf:
Error:\tApache has not been designed to serve pages while\n\trunning as root. There are known race conditions that\n\twill allow any local user to read any file on the system.\n\tIf you still desire to serve pages as root then\n\tadd -DBIG_SECURITY_HOLE to the CFLAGS env variable\n\tand then rebuild the server.\n\tItis strongly suggested that you instead modify the User\n\tdirective in your httpd.conf file to list a non-root\n\tuser.\n

这种情况首先是由于,使用root用户的缘故,参照上述所改apache.conf中内容应该修改如下:最好新建一个用户,apache,让它属于一个特定的组,如:apache。其它的先不考虑先改过来这个再说。

2.又出现了第二个错误:
[apache@localhost root]$ /usr/local/apache2/bin/apachectl start
(13)Permission denied: make_sock: could not bind to address [::]:80
no listening sockets available, shutting down

这种情况是由于80端口被占用的缘故!试着修改apache.conf,具体如下。
Listen 80    改为:Listen 8080
ServerName localhost:80        改为:ServerName localhost:8080

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

OK我的也成功了!

用ZendOptimizer加速PHP

#tar -zxvf ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz
#cd ZendOptimizer-3.0.1-linux-glibc21-i386
#./install.sh

安装的时候注意输入正确的安装apache的路径等内容!
安装完毕,再看看phpinfo页面的zend选项就发现了!!
当出现: Enter the location of your php.ini file 的提示时,输入:/usr/local/php/lib

── Zend Optimizer 3.0.1 ───────────

The following configuration changes have been made:
                                                                                     
- The php.ini file has been relocated from /usr/local/php/lib to /usr/local/Zend/etc
                                                                                   
- A symbolic link for the php.ini file has been created in /usr/local/php/lib.
                                                                                     
- The original php.ini was backed up to                                             
/usr/local/php/lib/php.ini-zend_optimizer.bak




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

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

编译安装php时提示Cannot find MySQL header files的解决方法

这是由于安装mysql时没有安装mysql头文件,或者是路径指定不正确,php找不到mysql的头文件引起的错误提示。

解决方法。
1. 查看你的系统有没有安装mysql header
   find / -name mysql.h
  如果有。请指定--with-mysql=/跟你的正常路径。
  如果没有。请看下一步。

2.redhat安装
  rpm -ivh MySQL-devel-4.1.12-1.i386.rpm

3.debian安装
  apt-get install libmysqlclient15-dev

4.最后一步php的配置选项添加--with-mysql=/usr即可!

不知道大家有没有遇到在  X64 RedHat5 或者 RedHat4 下.编译安装PHP环境的时候. 安装了libxml,zlib,jpeg,libpng,freetype,libart_lgpl,gettext...  到编译 GD 库的时候出错.

configure 的参数是

./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/ --with-libart=/usr/local/libart/ --with-gettext=/usr/local/gettext/ --with-libxml=/usr/local/libxml2
---------------------------

错误如下:

/usr/bin/ld: /usr/local/jpeg6//lib/libjpeg.a(jcapimin.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/jpeg6//lib/libjpeg.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libgd.la] 错误1
make[2]: Leaving directory `/data/soft/php/gd-2.0.35'
make[1]: *** [all-recursive] 错误1
make[1]: Leaving directory `/data/soft/php/gd-2.0.35'
make: *** [all] 错误2

到网上搜索,很多网友都说只需要修改 Makefile

vi Makefile
找到 CFLAGS= -O2 -I$(srcdir)
在后面加入-fPIC,即变成CFLAGS= -O2 -I$(srcdir) -fPIC

这样就可以继续编译了
但我在 gd-2.0.35  gd-2.0.33 以及 gd-2.0.36RC1 的 Makefile 里头,
都只找到 CFLAGS= -O2 并没有后边的 -I$(srcdir)
故此就算把-fPIC加上了,也毫无作用。
------------------------------------

开始着手研究,根据错误提示,应该是跟 jpeg6 有关,于是尝试使用另外方式对 jpeg6 进行编译。

原本网上最多的编译 jpeg6 的方法是 (注jpeg6下载地址http://www.ijg.org/)

-----------------------------
# tar -zxf jpegsrc.v6b.tar.gz
# cd jpeg-6b/
# ./configure --prefix=/usr/local/jpeg6
# make
# make install-lib
# make install
在32位上以这种方式安装是没问题的.但64的话,或许要改一改,如下:
-----------------------------
# tar -zxf jpegsrc.v6b.tar.gz
# cd jpeg-6b/
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make
# make install
----------------------------

但又会出个问题! 大多数环境在用这种方式编译jpeg6的时候都会出错(有够烦的,简直是一波三折),提示
make: ./libtool: Command not found
make: *** [jcapimin.lo] Error 127
---------------------------

错误分析:由于libtool版本过低导致的,重新下载新版本的libtool以默认方式安装.下载地址:ftp://ftp.gnu.org/gnu/libtool/
也不用下载太新,1.5.xx 既可。执行以下命令:
# tar zxvf libtool-1.5.26.tar.gz
# cd libtool-1.5.26
# ./configure
# make
# make install
(最好重新启动一下服务器,重新加载环境以确保正常)
然后进入jpeg-6b的源码目录,然后执行以下步骤,切记!
# cp /usr/local/share/libtool/config.sub ./
# cp /usr/local/share/libtool/config.guess ./
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make
# make install

---------------------------

好了!这下尝试执行GD 的 configure , 虽然依然是 libgd.la 错误,但提示的已经不是 jpeg6 的问题了。
这下是 freetype2 的问题了,如下:
---------------------------

/usr/bin/ld: /usr/local/freetype2/lib/libfreetype.a(ftinit.o): relocation R_X86_64_32 against `tt_driver_class' can not be used when making a shared object; recompile with -fPIC
/usr/local/freetype2/lib/libfreetype.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libgd.la] 错误1
make[2]: Leaving directory `/data/soft/php/gd-2.0.35'
make[1]: *** [all-recursive] 错误1
make[1]: Leaving directory `/data/soft/php/gd-2.0.35'
make: *** [all] 错误2
---------------------------

着看上去是freetype2 出错但其实是zlib安装问题
原本的编译方法就直接是:
---------------------------
# tar zxvf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
#./configure --prefix=/usr/local/zlib2/ && make && make install
在32位上以这种方式安装是没问题的.但64的话,要改一改,如下
---------------------------
解决方法:重新编译安装zlib,步骤如下:(在重新编译之前记得要把之前安装在/usr/local/zlib2里头的文件都完全删除)
# tar -zxvf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
#./configure
#vi Makefile
找到 CFLAGS=-O3 -DUSE_MMAP
在后面加入-fPIC,即变成CFLAGS=-O3 -DUSE_MMAP -fPIC
# make
# make install
-----------------------------
然后再重新编译 freetype (在重新编译之前记得要把之前安装在/usr/local/freetype里头的文件都完全删除)
#./configure --prefix=/usr/local/freetype2/ && make && make install

 Zlib 跟 freetype 的安装一定要按照顺序,不然解决不了问题.
-----------------------------

行了!这下子 freetype 也没问题了!但GD的编译还是不过,错误如下:

/usr/bin/ld: /usr/local/libpng2/lib/libpng12.a(libpng12_la-png.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/libpng2/lib/libpng12.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libgd.la] 错误1
make[2]: Leaving directory `/data/soft/php/gd-2.0.35'
make[1]: *** [all-recursive] 错误1
make[1]: Leaving directory `/data/soft/php/gd-2.0.35'
make: *** [all] 错误2
-----------------------------
libpng的问题,我们改一改编译以及安装的方式。跟上边2个一样,要先把/usr/local/libpng2 都删干净,然后再重新编译安装。
编译安装 libpng
#tar zxvf libpng-1.2.34.tar.gz
#cd libpng-1.2.34
#cp scripts/makefile.gcmmx makefile
#./configure --prefix=/usr/local/libpng2/
# vi Makefile
找到 CFLAGS = -g -O2 后边加上 -fPIC
# make && make install
-----------------------------

好了,真像玩游戏过三关的样子.....
把最后这 libpng 也解决了,这GD也总算是编译好了。
接下来终于能编译  php-5.2.6

# tar zxvf php-5.2.6.tar.gz
# cd php-5.2.6
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng2/ --with-gd=/usr/local/gd2/ --with-freetype-dir=/usr/local/freetype2/  --with-zlib-dir=/usr/local/zlib2/ -with-mysql=/usr/local/mysql  --with-curl=/usr/local/curl --with-gettext=/usr/local/gettext

好了! 又卡住了!!!!!
如果 mysql 是使用rpm方式安装,除了安装server跟client记得装上其开发包 MySQL-devel-community
如果你的mysql是装在另外一台机器,这么你编辑安装php也只需装上 MySQL-client-community 跟 MySQL-devel-community
不然php ./configure  的时候会出现找不到 mysql 的错误

#####################

如果你已经安装了上述说的rpm包,或者是以编译方式安装mysql的,还是出错,并提示 Cannot find libmysqlclient_r 。

如下:

checking for MySQL support… yes checking for specified location of the MySQL UNIX socket… no checking for MySQL UNIX socket location… no configure: error: Cannot find libmysqlclient_r under /usr/local/mysql. Note that the MySQL client library is not bundled anymore!

-----------------------------

或者是:

checking for MySQL support… yes checking for specified location of the MySQL UNIX socket… no checking for MySQL UNIX socket location… no configure: error: Cannot find libmysqlclient_r under /usr. Note that the MySQL client library is not bundled anymore!

-----------------------------

那么,你需要注意了,你可能在编译APACHE的时候,使用–with-mpm模块,请在编译MYSQL的时候加上 –enable-thread-safe-client.

这是PHP5.2的一个改进,在PHP5.2.0之前的版本都不需要MYSQL启用安全线程。 因此在安装MYSQL时,configure应该是: ./configure prefix=/usr/local/mysql –with-extra-charsets=all –enable-thread-safe-client

如果是rpm安装的话,经过一番研究,得出所需文件 libmysqlclient rpm包默认安装在了 /usr/lib64/mysql 下。

但PHP编译的时候找的是 /usr/lib/mysql 所以就找不到了。

这么好办,做个软连接即刻解决 ln -s /usr/lib64/mysql /usr/lib

这样就会有了 /usr/lib/mysql 这一路径,PHP编译顺利通过!

最后 ZendOptimizer 也需要装上 X64 版本.最新下载地址为:

http://downloads.phpchina.com/zend/optimizer/

 

不知道大家有没有遇到在  X64 RedHat5 或者 RedHat4 下.编译安装PHP环境的时候. 安装了libxml,zlib,jpeg,libpng,freetype,libart_lgpl,gettext...  到编译 GD 库的时候出错.

configure 的参数是

./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/ --with-libart=/usr/local/libart/ --with-gettext=/usr/local/gettext/ --with-libxml=/usr/local/libxml2
---------------------------

错误如下:

/usr/bin/ld: /usr/local/jpeg6//lib/libjpeg.a(jcapimin.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/jpeg6//lib/libjpeg.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libgd.la] 错误1
make[2]: Leaving directory `/data/soft/php/gd-2.0.35'
make[1]: *** [all-recursive] 错误1
make[1]: Leaving directory `/data/soft/php/gd-2.0.35'
make: *** [all] 错误2

到网上搜索,很多网友都说只需要修改 Makefile

vi Makefile
找到 CFLAGS= -O2 -I$(srcdir)
在后面加入-fPIC,即变成CFLAGS= -O2 -I$(srcdir) -fPIC

这样就可以继续编译了
但我在 gd-2.0.35  gd-2.0.33 以及 gd-2.0.36RC1 的 Makefile 里头,
都只找到 CFLAGS= -O2 并没有后边的 -I$(srcdir)
故此就算把-fPIC加上了,也毫无作用。
------------------------------------

开始着手研究,根据错误提示,应该是跟 jpeg6 有关,于是尝试使用另外方式对 jpeg6 进行编译。

原本网上最多的编译 jpeg6 的方法是 (注jpeg6下载地址http://www.ijg.org/)

-----------------------------
# tar -zxf jpegsrc.v6b.tar.gz
# cd jpeg-6b/
# ./configure --prefix=/usr/local/jpeg6
# make
# make install-lib
# make install
在32位上以这种方式安装是没问题的.但64的话,或许要改一改,如下:
-----------------------------
# tar -zxf jpegsrc.v6b.tar.gz
# cd jpeg-6b/
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make
# make install
----------------------------

但又会出个问题! 大多数环境在用这种方式编译jpeg6的时候都会出错(有够烦的,简直是一波三折),提示
make: ./libtool: Command not found
make: *** [jcapimin.lo] Error 127
---------------------------

错误分析:由于libtool版本过低导致的,重新下载新版本的libtool以默认方式安装.下载地址:ftp://ftp.gnu.org/gnu/libtool/
也不用下载太新,1.5.xx 既可。执行以下命令:
# tar zxvf libtool-1.5.26.tar.gz
# cd libtool-1.5.26
# ./configure
# make
# make install
(最好重新启动一下服务器,重新加载环境以确保正常)
然后进入jpeg-6b的源码目录,然后执行以下步骤,切记!
# cp /usr/local/share/libtool/config.sub ./
# cp /usr/local/share/libtool/config.guess ./
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make
# make install

---------------------------

好了!这下尝试执行GD 的 configure , 虽然依然是 libgd.la 错误,但提示的已经不是 jpeg6 的问题了。
这下是 freetype2 的问题了,如下:
---------------------------

/usr/bin/ld: /usr/local/freetype2/lib/libfreetype.a(ftinit.o): relocation R_X86_64_32 against `tt_driver_class' can not be used when making a shared object; recompile with -fPIC
/usr/local/freetype2/lib/libfreetype.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libgd.la] 错误1
make[2]: Leaving directory `/data/soft/php/gd-2.0.35'
make[1]: *** [all-recursive] 错误1
make[1]: Leaving directory `/data/soft/php/gd-2.0.35'
make: *** [all] 错误2
---------------------------

着看上去是freetype2 出错但其实是zlib安装问题
原本的编译方法就直接是:
---------------------------
# tar zxvf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
#./configure --prefix=/usr/local/zlib2/ && make && make install
在32位上以这种方式安装是没问题的.但64的话,要改一改,如下
---------------------------
解决方法:重新编译安装zlib,步骤如下:(在重新编译之前记得要把之前安装在/usr/local/zlib2里头的文件都完全删除)
# tar -zxvf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
#./configure
#vi Makefile
找到 CFLAGS=-O3 -DUSE_MMAP
在后面加入-fPIC,即变成CFLAGS=-O3 -DUSE_MMAP -fPIC
# make
# make install
-----------------------------
然后再重新编译 freetype (在重新编译之前记得要把之前安装在/usr/local/freetype里头的文件都完全删除)
#./configure --prefix=/usr/local/freetype2/ && make && make install

 Zlib 跟 freetype 的安装一定要按照顺序,不然解决不了问题.
-----------------------------

行了!这下子 freetype 也没问题了!但GD的编译还是不过,错误如下:

/usr/bin/ld: /usr/local/libpng2/lib/libpng12.a(libpng12_la-png.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/libpng2/lib/libpng12.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [libgd.la] 错误1
make[2]: Leaving directory `/data/soft/php/gd-2.0.35'
make[1]: *** [all-recursive] 错误1
make[1]: Leaving directory `/data/soft/php/gd-2.0.35'
make: *** [all] 错误2
-----------------------------
libpng的问题,我们改一改编译以及安装的方式。跟上边2个一样,要先把/usr/local/libpng2 都删干净,然后再重新编译安装。
编译安装 libpng
#tar zxvf libpng-1.2.34.tar.gz
#cd libpng-1.2.34
#cp scripts/makefile.gcmmx makefile
#./configure --prefix=/usr/local/libpng2/
# vi Makefile
找到 CFLAGS = -g -O2 后边加上 -fPIC
# make && make install
-----------------------------

好了,真像玩游戏过三关的样子.....
把最后这 libpng 也解决了,这GD也总算是编译好了。
接下来终于能编译  php-5.2.6

# tar zxvf php-5.2.6.tar.gz
# cd php-5.2.6
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg6/ --with-png-dir=/usr/local/libpng2/ --with-gd=/usr/local/gd2/ --with-freetype-dir=/usr/local/freetype2/  --with-zlib-dir=/usr/local/zlib2/ -with-mysql=/usr/local/mysql  --with-curl=/usr/local/curl --with-gettext=/usr/local/gettext

好了! 又卡住了!!!!!
如果 mysql 是使用rpm方式安装,除了安装server跟client记得装上其开发包 MySQL-devel-community
如果你的mysql是装在另外一台机器,这么你编辑安装php也只需装上 MySQL-client-community 跟 MySQL-devel-community
不然php ./configure  的时候会出现找不到 mysql 的错误

#####################

如果你已经安装了上述说的rpm包,或者是以编译方式安装mysql的,还是出错,并提示 Cannot find libmysqlclient_r 。

如下:

checking for MySQL support… yes checking for specified location of the MySQL UNIX socket… no checking for MySQL UNIX socket location… no configure: error: Cannot find libmysqlclient_r under /usr/local/mysql. Note that the MySQL client library is not bundled anymore!

-----------------------------

或者是:

checking for MySQL support… yes checking for specified location of the MySQL UNIX socket… no checking for MySQL UNIX socket location… no configure: error: Cannot find libmysqlclient_r under /usr. Note that the MySQL client library is not bundled anymore!

-----------------------------

那么,你需要注意了,你可能在编译APACHE的时候,使用–with-mpm模块,请在编译MYSQL的时候加上 –enable-thread-safe-client.

这是PHP5.2的一个改进,在PHP5.2.0之前的版本都不需要MYSQL启用安全线程。 因此在安装MYSQL时,configure应该是: ./configure prefix=/usr/local/mysql –with-extra-charsets=all –enable-thread-safe-client

如果是rpm安装的话,经过一番研究,得出所需文件 libmysqlclient rpm包默认安装在了 /usr/lib64/mysql 下。

但PHP编译的时候找的是 /usr/lib/mysql 所以就找不到了。

这么好办,做个软连接即刻解决 ln -s /usr/lib64/mysql /usr/lib

这样就会有了 /usr/lib/mysql 这一路径,PHP编译顺利通过!

最后 ZendOptimizer 也需要装上 X64 版本.最新下载地址为:

http://downloads.phpchina.com/zend/optimizer/

 

http://ldzyz007.iteye.com/blog/1456673
http://www.oschina.net/question/17_87
 
 
 

php编译错误Note that the MySQL client library is not bundled anymore!

php编译错误Note that the MySQL client library is not bundled anymore! ##### install php
##download http://jp.php.net/downloads.php
wget http://jp.php.net/get/php-5.2.9.tar.gz/from/this/mirror
rpm -qa | grep php
rpm -e php-ldap-5.1.6-20.el5 php-5.1.6-20.el5

tar -zxvf php-5.2.9.tar.gz
cd php-5.2.9
./configure --prefix=/usr/local/php --with-mysql=/usr/local/src/mysql-5.1.14-beta-linux-i686-glibc23/include/ --with-apxs2=/usr/local/apache2/bin/apxs
到最后报错:
configure: error: Cannot find MySQL header files under /usr/local/src/mysql-5.1.14-beta-linux-i686-glibc23/include/.
Note that the MySQL client library is not bundled anymore!

解决方法。
1. 查看系统有没有安装mysql header
find / -name mysql.h
如果有。请指定--with-mysql=/跟正常路径。
如果没有。请看下一步。

2.redhat安装
rpm -ivh MySQL-devel-community-5.1.33-0.rhel5.i386.rpm

3.最后一步php的配置选项添加--with-mysql=/usr即可!

完整的编译参数:
  1. /configure --with-apxs2=/usr/local/apache2/bin/apxs --includedir=/usr/local/include --enable-force-cgi-redirect --enable-mailparse --enable-mbstring --enable-mbregex --enable-mbstr-enc-trans --enable-trans-sid --enable-shmop --enable-exif --with-gd --with-jpeg-dir=/usr/local/lib/ --with-png-dir=/usr/local/lib/ --with-zlib-dir=/usr/include/ --enable-gd-native-ttf --enable-gd-jis-conv --with-pgsql=/usr/local/pgsql --with-mysql=/usr/local/mysql --enable-sockets --enable-ftp --with-curl=/usr/local/ --enable-memcache --enable-openssl  

 

 

本文测试环境Red Hat Enterprise 5.4,均为源码编译安装,以下下载安装包注意“保质期”,随时有可能连不上,也可能因为版本太老被转移地址,具体可到对应网站上查看最新地址。 以下安装过程少则一个小时,多则三五天都有可能,所以遇到问题不必着急。为保证在安装、编译过程系统干净性(亦有网友称天缘为强迫症的),下文操作一律在/tmp临时目录下进行,使用cd或cd..一定要对应,否则连续出错几次,自己都不清楚包被DOWN到哪里了。

一、准备编译环境

编译安装包之前,请确认您的gcc工具及版本情况:

gcc -v

至少应该包含gcc gcc/c++,libtool,autoconfi,automake等几个常用的。其中libtool是编译gd库和freetype时需要,版本太低也可能有问题。

安装编译环境命令如下:

# yum install gcc  gcc-c++  glibc  glibc-devel  gd  gd-devel  zlib  zlib-devel  libtool-ltdl-devel flex  autoconf  automake

该命令对REDHAT没注册的用户而言,无法在线安装,只能去下载包一个个源码编译安装。也可以直接找RPM、DEB包安装。本文从略,注意安装或更新编译环境后,记得重启机子一次。

如果下文安装GD、FREETYPE时总是报错,请安装或更新libtool,编译安装Libtool,更新这个,机子需要重启一下,否则在安装GD时,总是报告freetype错误。

view source
print?
1# cd /tmp
2# wget ftp://ftp.gnu.org/gnu/libtool/libtool-1.5.26.tar.gz
3# tar zxvf libtool-1.5.26.tar.gz
4# cd libtool-1.5.26
5# ./configure
6# make
7# make install

二、安装apache

view source
print?
1# cd /tmp
2# wget http://www.apache.org/dist/httpd/httpd-2.2.22.tar.gz
3# tar zxvf httpd-2.2.22.tar.gz
4# cd httpd-2.2.22
5# ./configure  --prefix=/usr/local/apache2 --enable-so --enable-rewrite
6# make && make install

如果需要为APACHE开启SSL,还需增加--enable-ssl --with-ssl=/usr/local/openssl配置选项,所以openssl也需先安装,请参考稍后文章。

启动apache:

# /usr/local/apache2/bin/apachectl start

设APACHE为服务:

# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd

修改刚拷贝过去的httpd:

在#!/bin/sh一行下,增加:

# chkconfig: 2345 10 90

# description: Activates/Deactivates Apache Web Server

然后保存退出。使用chkconfig --add httpd即可设置为服务,开机启动。但是毕竟是apachectl,启动停止时均没有提示。

APACHE基本设置:

Apache安装完后,配置文件httpd.conf需添加对php解析支持,路径/usr/local/apache2/conf/httpd.conf。

添加:AddType application/x-httpd-php .php

修改:DirectoryIndex index.html index.php

三、安装mysql数据库

1、安装ncurse:

ncurse介绍,安装方法如下:

view source
print?
1# cd /tmp
2# wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
3# tar zxvf ncurses-5.6.tar.gz
4# cd ncurses-5.6
5# ./configure
6# make && make install

要编译最新的MYSQL还需要使用CMAKE和BISON(BISON介绍),如果本机有则不必安装。

2、安装cmake:

view source
print?
1# cd /tmp
2# wget http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz
3# tar zxvf cmake-2.8.7.tar.gz
4# cd cmake-2.8.7
5# ./bootstrap
6# gmake
7# gmake install

cmake命令文件安装到了/usr/local/bin目录下

3、安装Bison:

view source
print?
1# cd /tmp
2# wget http://ftp.gnu.org/gnu/bison/bison-2.5.tar.gz
3# tar zxvf bison-2.5.tar.gz
4# cd bison-2.5
5# ./configure
6# make && make install

4、安装MYSQL:

view source
print?
1# cd /tmp
2# wget http://mirror.trouble-free.net/mysql_mirror/Downloads/MySQL-5.5/mysql-5.5.22.tar.gz
3# tar zxvf mysql-5.5.22.tar.gz
4# cd mysql-5.5.22
5# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql
6# make && make install

cmake几个参数介绍:

  • -DCMAKE_INSTALL_PREFIX=/data/mysql ->mysql的安装路径
  • -DDEFAULT_CHARSET=utf8 ->默认字符集
  • -DMYSQL_TCP_PORT=3306  ->监听端口
  • -DMYSQL_UNIX_ADDR=/tmp/mysql.sock  ->数据库unix socket
  • -DWITH_DEBUG=0  ->关闭debug模式
  • -DWITH_INNOBASE_STORAGE_ENGINE=1  ->打开innodb引擎

添加群组:

  • # groupadd mysql
  • # useradd -g mysql mysql

修改权限及归属:

  • # chmod +w /usr/local/mysql
  • # chown -R mysql:mysql /usr/local/mysql

增加链接:

  • # ln -s /usr/local/mysql/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16

准备配置文件:

  • # cd /usr/local/mysql/support-files/
  • # cp my-large.cnf /etc/my.cnf (有my-large.cnf和my-huge.cnf可供选择,随内存大小定)
  • # cp mysql.server /etc/init.d/mysqld

MYSQL数据库初始化:

如需修改my.cnf,可以访问/etc/my.cnf,MYSQL初始化(特别注意参数中的几个路径与cmake配置,以及下文修改启动文件中路径需要统一):

  • /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

设置开机启动:

  • chmod +x /etc/init.d/mysqld
  • vi /etc/init.d/mysqld (编辑此文件,查找并修改以下变量内容:)
  • basedir=/usr/local/mysql
  • datadir=/usr/local/mysql/data
  • chkconfig --add mysqld
  • chkconfig --level 345 mysqld on

启动 mysql:

  • service mysqld start

测试进入:

  • # /usr/local/mysql/bin/mysqladmin  -u root password
  • # /usr/local/mysql/bin/mysql -u root -p

修改root密码

  • # /usr/local/mysql/bin/mysqladmin -u root password '111111'

四、安装GD库

1、编译安装libxml

view source
print?
1# cd /tmp
2# wget http://xmlsoft.org/sources/libxml2-2.7.8.tar.gz
3# tar zxvf libxml2-2.7.8.tar.gz
4# cd libxml2-2.7.8
5# ./configure --prefix=/usr/local/libxml2/
6# make && make install

2、编译安装zlib

下面安装libpng前要安装zlib,参考:http://fruithardcandy.iteye.com/blog/1460647。

view source
print?
01# cd /tmp
02# wget http://www.zlib.net/zlib-1.2.3.tar.gz
03# tar zxvf zlib-1.2.3.tar.gz
04# # cd zlib/1.2.3/
05# ./configure --prefix=/usr/local/zlib2/
0664位要改:
07#vi Makefile
08找到 CFLAGS=-O3 -DUSE_MMAP
09在后面加入-fPIC,即变成CFLAGS=-O3 -DUSE_MMAP -fPIC
10# make && make install

3、编译安装jpeg

view source
print?
01# cd /tmp
02# wget http://quirkysoft.googlecode.com/files/jpegsrc.v6b.tar.gz
03# mkdir-pv /usr/local/jpeg6{,bin,lib,include,man/man1,man1}
04# tar zxvf jpegsrc.v6b.tar.gz
05# cd jpeg-6b
0664位系统要执行如下两句:
07# cp /usr/local/share/libtool/config.sub ./
08# cp /usr/local/share/libtool/config.guess ./
0932位系统用:
10# ./configure --prefix=/usr/local/jpeg6
1164位系统用:
12# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
13# make
14# make install-lib
15# make install

4、编译安装libpng

view source
print?
1# cd /tmp
2# wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.4.11.tar.gz
3# tar zxvf libpng-1.4.11.tar.gz
4# cd libpng-1.4.11
5下面这句,天缘测试不能执行,否则就会报告下面的错误,而且无法安装到/usr/lib/libpn/下
6# cp scripts/makefile.linux makefile
7# ./configure --prefix=/usr/local/libpng/
8# make && make install

如果执行上文的cp script...命令,最后安装PHP时会总是报告:

./conftest: error while loading shared libraries: libpng14.so.14: cannot open shared object file: No such file or directory
错误。

经查,libpng相关文件并没有安装到/usr/local/libpng下面,只是把库libpng14.so.14.11拷贝到/usr/local/lib/下,实际的libpng14.so.14文件却在原编译目录下,即使尝试为它创建链接也无法解决上述错误。最后干脆直接去掉该句,反倒好了。

5、编译安装freetype

view source
print?
1# cd /tmp
2# wget http://oss.oetiker.ch/rrdtool/pub/libs/freetype-2.3.5.tar.gz
3# tar zxvf freetype-2.3.5.tar.gz
4# cd freetype-2.3.5
5# ./configure --prefix=/usr/local/freetype2/
6# make && make install

6、安装GD库:

注意configure参数对应上文各路径是否正确,如果没装可对应去掉该项参数。

view source
print?
1# cd /tmp
2# wget http://google-desktop-for-linux-mirror.googlecode.com/files/gd-2.0.35.tar.gz
3# tar zxvf gd-2.0.35.tar.gz
4# cd gd/2.0.35/
5# ./configure --prefix=/usr/local/gd2 --with-zlib=/usr/local/zlib2/ --with-png=/usr/local/libpng/ --with- jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype2/ --with-libart=/usr/local/libart/ --with-gettext=/usr/local/gettext/ --with-libxml=/usr/local/libxml2
6我的配置:
7# ./configure --prefix=/usr/local/gd2 --with-zlib=/usr/local/zlib2/ --with-png=/usr/local/libpng/ --with- jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype2/ --with-libxml=/usr/local/libxml2
8# cp /usr/lib/libattr.* /lib/
9# make && make install

五、安装PHP及curl、ZendOptimizer支持

1、编译安装Curl支持:

view source
print?
1# cd /tmp
2# wget http://dl.ambiweb.de/mirrors/curl.haxx.se/curl-7.15.0.tar.gz
3# tar zxvf curl-7.15.0.tar.gz
4# cd curl-7.15.0
5# ./configure --prefix=/usr/local/curl
6# make && make install

2、libmcrypt库一般也需要:

view source
print?
1# cd /tmp
2#tar zxvf libmcrypt-2.5.7.tar.gz
3#cd libmcrypt-2.5.7
4#./configure  --prefix=/usr/local/libmcrypt
5#make
6#make  install

3、编译安装PHP:

view source
print?
1# cd /tmp
2#wget http://download.huihoo.com/php/php-5.4.0.tar.gz
3#tar zxvf php-5.4.0.tar.gz
4#cd php-5.4.0
5# ./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql/ --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg6/ --with-freetype-dir=/usr/local/freetype2/ --with-zlib --with-png-dir=usr/local/libpn2 --with-libxml-dir=/usr/local/libxml2 --with-gd --with-mcrypt=/usr/local/libmcrypt/ --enable-ftp --enable-sockets
6我的配置:
7# ./configure --prefix=/usr/local/php5  --with-config-file-path=/usr/local/php5 --with-mysql=/usr/local/mysql/ --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg6/ --with-freetype-dir=/usr/local/freetype2/ --with-zlib-dir=/usr/local/zlib/ --with-png-dir=/usr/local/libpng/ --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd2/ --with-mysqli=/usr/local/mysql/bin/mysql_config
8#make && make install

其中--with-config-file-path指定加载PHP配置文件路径。如果不设置,那么PHP无法找到Loaded Configuration File路径(phpinfo里可查看)。

--with-mysqli=/usr/local/mysql/bin/mysql_config是为了增加mysqli支持,但是问题由此而来,测试编译php-5.2.6时总是出现某个变量未定义现象,之后改成5.4.0又出现struct gdIOCtx中没有data指针定义,最后修改/usr/local/gd2/include/gd_io.h,gdIOCtx结构中增加void *data;这才编译通过。

从源码中拷贝PHP配置文件:

  • # cp php.ini-dist /usr/local/php5/php.ini

修改/usr/local/php5/php.ini文件,如果有额外模块需要加载,修改extension_dir- = "./" 为 extension_dir- = "./include/php/ext"。

4、安装ZendOptimizer:

view source
print?
1# cd /tmp
2# tar zxvf ZendOptimizer-3.3.0a-linux-glibc21-i386.tar.gz
3# cd ZendOptimizer-3.3.0a-linux-glibc21-i386
4# ./install

5、安装phpmyadmin:

view source
print?
1# cd /tmp
2# tar jxvf phpMyAdmin-2.11.9.4-all-languages-utf-8-only.tar.bz2
3# mv phpMyAdmin-2.11.9.4-all-languages-utf-8-only /usr/local/apache/htdocs/
4# cd /usr/local/apache/htdocs/
5# cp libraries/config.default.php  config.inc.php

phpmyadmin在使用前还需修改配置文件,config.inc.php,设置数据库访问名称、密码等,本文从略。

六、安装结束

重启apache服务:

service httpd restart

重启mysql:

service mysqld restart

此两步难顺利者十之八九,多次摸索之后一般均可解决。 

参考资料:

http://www.oschina.net/question/17_87,几个问题都是从TA的文章中得到解决方法。

http://www.linuxidc.com/Linux/2012-04/58140.htm 介绍源码编译MYSQL 5.5.22

http://zhengdl126.iteye.com/blog/481183 介绍CentOS下安装LAMP

 

 

 

 

http://httpd.apache.org/docs/2.2/programs/apxs.html

http://bbs.ecshop.com/thread-36453-2-7.html

http://www.quyu.co/thread-34-1-1.html

http://comtv.blog.51cto.com/17037/399566

 

http://www.optix.org/~dxy/solaris/jpegsrc/

 

 

 

http://blog.yntv.cn/html/28/28-360.html
http://blog.csdn.net/jianguo_liao19840726/article/details/7222814
http://blog.163.com/bdweizhong@yeah/blog/static/963698182010626095858/
 
 

原创粉丝点击