Debian GNU/Linux 8.4 (jessie)编译安装php.md

来源:互联网 发布:java安卓4.4.4模拟器 编辑:程序博客网 时间:2024/06/05 15:16

编译遇到的问题很多。网上的文章往往是记录遇到的报错,贴上对应的解决。
而实际的环境,如操作系统,安装的软件必然有差异,所以,更重要的是,如何找到解决方法(不担保按步骤做可以编译成功),并将过程自动化。

安装php-dev

apt-get install php5-dev

安装phpize、autoconf、php-config等configure安装需要的命令

configure 安装三步曲 (configure,make,install三步)

先进入php源码目录

  • ./buildconf --force
  • configure
  • make -j4
  • make install

    获得php原configure参数

    因为要替换包安装的的php,首先获得configure参数

    php-config --configure-optionsxxxx@xxxx:/etc/php5/apache2$ php-config --configure-options--prefix=/usr --with-apxs2=/usr/bin/apxs2 --with-config-file-path=/etc/php5/apache2 --with-config-file-scan-dir=/etc/php5/apache2/conf.d --build=x86_64-linux-gnu --host=x86_64-linux-gnu --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --disable-debug --with-regex=php --disable-rpath --disable-static --with-pic --with-layout=GNU --with-pear=/usr/share/php --enable-calendar --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-bcmath --with-bz2 --enable-ctype --with-db4 --with-qdbm=/usr --without-gdbm --with-iconv --enable-exif --enable-ftp --with-gettext --enable-mbstring --with-onig=/usr --with-pcre-regex=/usr --enable-shmop --enable-sockets --enable-wddx --with-libxml-dir=/usr --with-zlib --with-kerberos=/usr --with-openssl=/usr --enable-soap --enable-zip --with-mhash=yes --with-system-tzdata --with-mysql-sock=/var/run/mysqld/mysqld.sock --enable-dtrace --without-mm --with-curl=shared,/usr --with-enchant=shared,/usr --with-zlib-dir=/usr --with-gd=shared,/usr --enable-gd-native-ttf --with-gmp=shared,/usr --with-jpeg-dir=shared,/usr --with-xpm-dir=shared,/usr/X11R6 --with-png-dir=shared,/usr --with-freetype-dir=shared,/usr --with-vpx-dir=shared,/usr --with-imap=shared,/usr --with-imap-ssl --enable-intl=shared --without-t1lib --with-ldap=shared,/usr --with-ldap-sasl=/usr --with-mcrypt=shared,/usr --with-mysql=shared,/usr --with-mysqli=shared,/usr/bin/mysql_config --with-pspell=shared,/usr --with-unixODBC=shared,/usr --with-recode=shared,/usr --with-xsl=shared,/usr --with-snmp=shared,/usr --with-sqlite3=shared,/usr --with-mssql=shared,/usr --with-tidy=shared,/usr --with-xmlrpc=shared --with-pgsql=shared,/usr PGSQL_INCLUDE=/usr/include/postgresql --enable-pdo=shared --without-pdo-dblib --with-pdo-mysql=shared,/usr --with-pdo-odbc=shared,unixODBC,/usr --with-pdo-pgsql=shared,/usr/bin/pg_config --with-pdo-sqlite=shared,/usr --with-pdo-dblib=shared,/usr --with-interbase=shared,/usr --with-pdo-firebird=shared,/usr build_alias=x86_64-linux-gnu host_alias=x86_64-linux-gnu CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -fsigned-char -fno-strict-aliasing -g LDFLAGS=-Wl,-z,relro CPPFLAGS=-D_FORTIFY_SOURCE=2 CXXFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security

    configure 常见错误

    bison版本问题

    configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: 3.0, min: 204, excluded: 3.0).checking for re2c... noconfigure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.configure: error: bison is required to build PHP/Zend when building a GIT checkout!vim configureline:5268bison_version_exclude=""

    php-config 生成参数包含 -O2 等 configure 不支持的参数

    configure: error: unrecognized option: `-O2'

    看起来是php-config生成的结果不能直接传入configure,把 CFLAGS 后的参数全部去掉。去掉--disable-debug,加上--enable-debug --enable-mysqlnd=shared——自己编译的目的就是打开调试。

    没有装安装包、或有安装对应的包,但路径不对

    此类报错数量非常多,总结一下:
  • 一般情况下,可以google报错信息。
  • 查看config.log config.m4 中的内容。找到包名,在https://packages.debian.org/search搜索
  • find 命令查找缺失的文件,看configure命令指定的路径,ln解决

具体报错

  • configure: error: Cannot find sys/sdt.h which is required for DTrace support

    xxxx@xxxx:~$ sudo apt-get install systemtap-sdt-dev
  • configure: error: DBA: Could not find necessary header file(s).

    xxxx@xxxx:~/workspace/php-src-php-5.6.30$ find . -name "*.m4" | xargs grep "DBA: Could not find necessary " -n./ext/dba/config.m4:32:    AC_MSG_ERROR([DBA: Could not find necessary header file(s).])./ext/dba/config.m4:35:    AC_MSG_ERROR([DBA: Could not find necessary library.])./ext/dba/config.m4:235:    AC_MSG_ERROR([DBA: Could not find necessary header file(s).])./ext/dba/config.m4:299:    AC_MSG_ERROR([DBA: Could not find necessary library.])// 得知需要找到 db4,qdbm的package,可以在// https://packages.debian.org/search?suite=default&section=all&arch=amd64&searchon=names&keywords=db4// 搜索并安装xxxx@xxxx:~$ wget http://security.debian.org/debian-security/pool/updates/main/d/db4.8/db4.8-util_4.8.30-12+deb7u1_amd64.debxxxx@xxxx:~$ sudo dpkg -i db4.8-util_4.8.30-12+deb7u1_amd64.deb 仍然不行,干掉--with-db4=/usr --with-qdbm=/usr --without-gdbm
  • configure: error: Unable to find gd.h anywhere under /usr

    xxxx@xxxx:~$ sudo find / -name "gd.h"/home/xxxx/workspace/php-src-php-5.6.30/ext/gd/libgd/gd.h将--with-gd=shared,/usr 改为--with-gd=shared
  • configure: error: Unable to locate gmp.h

    xxxx@xxxx:~$ sudo find / -name "gmp.h"/usr/include/x86_64-linux-gnu/gmp.hxxxx@xxxx:~$ sudo ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h
  • configure: error: libgds, libib_util or libfbclient not found! Check config.log for more information.

    搜索得到jessie (oldstable) (libs): Firebird client library 2.5.3.26778.ds4-5+deb8u1: amd64xxxx@xxxx:~/deb$ wget http://ftp.cn.debian.org/debian/pool/main/f/firebird2.5/libfbclient2_2.5.3.26778.ds4-5+deb8u1_amd64.debxxxx@xxxx:~/deb$ sudo dpkg -i libfbclient2_2.5.3.26778.ds4-5+deb8u1_amd64.debxxxx@xxxx:/usr/lib$ sudo apt-get install firebird-dev仍然报错,查看config.log/usr/bin/ld: cannot find -lfbclientxxxx@xxxx:/usr/lib$ sudo find / -name "libfbclient.so*"/usr/lib/x86_64-linux-gnu/libfbclient.so.2.5.3/usr/lib/x86_64-linux-gnu/libfbclient.so.2xxxx@xxxx:/usr/lib$ sudo ln -s /usr/lib/x86_64-linux-gnu/libfbclient.so.2.5.3 /usr/lib/libfbclient.so
  • configure: error: Cannot find ldap libraries in /usr/lib.

    xxxx@xxxx:/usr/lib$ sudo ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so
  • configure: error: oniguruma.h not found in /usr/include

    sudo apt-get install libonig-dev
原创粉丝点击