Linux编译PHP问题整理

VN:F [1.9.10_1130]
Rating: 0.0/5 (0 votes cast)

对于Linux我是个新手,更希望使用Debain的Apt的库解决。没办法用了Red Hat,虽然最终装了Apt但是库包实在太少,无奈之下,只好手工编译。

遇到的问题其实主要原因有两个:一个是RHEL所带的包不能满足要求;还有一个就是Make安装的设置不正确。

关于Make,这里有篇文章简单易懂《Linux编译套件》。

Linux默认安装目录

一般情况下GNU规范的构建都会安装到 /usr/local目录下。但是很多系统服务组件,习惯于到 /usr目录下,这时候,我们就需要设置路径参数。如

./configure –prefix=/usr

错误举例

ext/iconv/iconv.o: In function `_php_iconv_mime_encode':
/home/ryan/php-5.2.9/ext/iconv/iconv.c:1043: undefined reference to `libiconv_open'

http://ru2.php.net/manual/en/ref.iconv.php#23700

错误原因:PHP构建参数不正确,应当根据安装iconv时配置设定,如: ‘–with-iconv=/usr’

./configure ‘–with-iconv=/usr’

配置检查失败:需要下载对应的软件包

正确的构建顺序

  1. wget phpXX.gz
  2. 解压缩程序
  3. 进入目录,执行 ./configure {其他参数}
  4. 发现错误:通常需要下载和安装对应组件包,安装成功后重复3
  5. 没有错误:执行 make clean
  6. 执行 make
  7. 发现错误:通常需要下载和安装对应组件包,安装成功后重复5
  8. 执行 make install

以下为参考的样例安装配置

配置Apache2

./configure --prefix=/usr/local/apache
	--enable-so
	--enable-cgi
	--enable-info
	--enable-rewrite
	--enable-speling
	--enable-usertrack
	--enable-deflate
	--enable-ssl
	--enable-mime-magic

配置PHP

./configure ‘–with-apxs2=/usr/local/apache2/bin/apxs’ ‘–build=i686-redhat-linux-gnu’ ‘–host=i686-redhat-linux-gnu’ ‘–target=i386-redhat-linux-gnu’ ‘–program-prefix=’ ‘–prefix=/usr’ ‘–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-libdir=lib’ ‘–with-config-file-path=/etc’ ‘–with-config-file-scan-dir=/etc/php.d’ ‘–disable-debug’ ‘–with-pic’ ‘–disable-rpath’ ‘–without-pear’ ‘–with-bz2′ ‘–with-curl’ ‘–with-exec-dir=/usr/bin’ ‘–with-freetype-dir=/usr’ ‘–with-png-dir=/usr’ ‘–enable-gd-native-ttf’ ‘–without-gdbm’ ‘–with-gettext’ ‘–with-gmp’ ‘–with-iconv=/usr’ ‘–with-jpeg-dir=/usr’ ‘–with-png’ ‘–with-expat-dir=/usr’ ‘–with-pcre-regex=/usr’ ‘–with-zlib’ ‘–with-layout=GNU’ ‘–enable-exif”–enable-magic-quotes’ ‘–enable-sockets’ ‘–enable-sysvsem’ ‘–enable-sysvshm’ ‘–enable-sysvmsg’ ‘–enable-track-vars’ ‘–enable-trans-sid’ ‘–enable-yp’ ‘–enable-wddx’ ‘–with-kerberos’ ‘–enable-ucd-snmp-hack’ ‘–enable-memory-limit’ ‘–enable-shmop’ ‘–enable-calendar’ ‘–enable-dbx’ ‘–enable-dio’ ‘–enable-so’ ‘–with-mime-magic=/usr/share/file/magic.mime’ ‘–without-sqlite’ ‘–with-libxml-dir=/usr’ ‘–with-xml’ ‘–with-system-tzdata’ ‘–enable-force-cgi-redirect’ ‘–enable-pcntl’ ‘–enable-mbstring=shared’ ‘–enable-mbstr-enc-trans’ ‘–enable-mbregex’ ‘–with-ncurses=shared’ ‘–with-gd=shared’ ‘–enable-bcmath=shared’ ‘–enable-dba=shared’ ‘–with-db4=/usr’ ‘–with-xmlrpc=shared’ ‘–with-mysql=/usr/bin/mysql_config’ ‘–with-mysqli=/usr/bin/mysql_config’ ‘–enable-dom=shared’ ‘–with-dom-xslt=/usr’ ‘–with-dom-exslt=/usr’ ‘–enable-soap=shared’ ‘–with-xsl=shared,/usr’ ‘–enable-xmlreader=shared’ ‘–enable-xmlwriter=shared’ ‘–enable-fastcgi’

您可能有兴趣的文章:

VN:F [1.9.10_1130]
Rating: 0.0/5 (0 votes cast)
Creative Commons License
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

2 Comments

  • 2009/04/27 - 8:18 AM | Permalink

    其实Redhat倒没什么,渣就渣在服务商只有盗版还不肯装别的,up2date实际上是很华丽的。

    VA:F [1.9.10_1130]
    Rating: 0 (from 0 votes)
    • 2009/04/29 - 1:23 AM | Permalink

      其实一圈弄下来,哪家有最多的支持,哪家就最高……
      rpm完全弄晕了我…

      莫非……
      乃没有选择Email提醒?于是我都不能测试新功能?

      VN:F [1.9.10_1130]
      Rating: 0 (from 0 votes)
  • Leave a Reply

    Your email address will not be published. Required fields are marked *

    *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>