Common Errors while installing PHP 5 from source in Ubuntu 10

If you try to install PHP 5.3.6 on Ubuntu by patching sources you will most likely see a lot of error messages similar to the following:

$ ./configure
cat: confdefs.h: No such file or directory
./configure: 490: ac_fn_c_try_run: not found
./configure: 490: 5: Bad file descriptor
./configure: 490: :: checking for pthreads_cflags: not found
./configure: 490: 6: Bad file descriptor
./configure: 490: checking for pthreads_cflags... : not found
cat: confdefs.h: No such file or directory
./configure: 490: ac_fn_c_try_run: not found
cat: confdefs.h: No such file or directory
./configure: 490: ac_fn_c_try_run: not found
cat: confdefs.h: No such file or directory
./configure: 490: ac_fn_c_try_run: not found
cat: confdefs.h: No such file or directory
./configure: 490: ac_fn_c_try_run: not found
cat: confdefs.h: No such file or directory
./configure: 490: ac_fn_c_try_run: not found
cat: confdefs.h: No such file or directory
./configure: 490: ac_fn_c_try_run: not found
cat: confdefs.h: No such file or directory
./configure: 490: ac_fn_c_try_run: not found
cat: confdefs.h: No such file or directory
./configure: 490: ac_fn_c_try_run: not found
./configure: 492: 5: Bad file descriptor
./configure: 492: :: result: : not found
./configure: 492: 6: Bad file descriptor
./configure: 492: : Permission denied
./configure: 495: 5: Bad file descriptor
./configure: 495: :: checking for pthreads_lib: not found
./configure: 495: 6: Bad file descriptor
./configure: 495: checking for pthreads_lib... : not found
cat: confdefs.h: No such file or directory
./configure: 555: ac_fn_c_try_run: not found
cat: confdefs.h: No such file or directory
./configure: 555: ac_fn_c_try_run: not found
cat: confdefs.h: No such file or directory
./configure: 555: ac_fn_c_try_run: not found
./configure: 557: 5: Bad file descriptor
./configure: 557: :: result: : not found
./configure: 557: 6: Bad file descriptor
./configure: 557: : Permission denied
./configure: 633: 5: Bad file descriptor
./configure: 633: :: result: : not found
./configure: 633: 6: Bad file descriptor
./configure: 633: : Permission denied
./configure: 635: 5: Bad file descriptor
./configure: 635: :: result: Configuring SAPI modules: not found
./configure: 635: 6: Bad file descriptor
./configure: 635: Configuring SAPI modules: not found
./configure: 666: 5: Bad file descriptor

See what happened when usingĀ buildconf earlier..

 $ ./buildconf --force
 Forcing buildconf
 buildconf: checking installation...
 buildconf: autoconf version 2.64 (ok)
 buildconf: Your version of autoconf likely contains buggy cache code.
 Running vcsclean for you.
 To avoid this, install autoconf-2.13.
 Can't figure out your VCS, not cleaning.

This is not a regular warning and it cannot be neglected. You have to use autoconf-2.13. This is because the newer version of autoconf cannot process scripts which are meant for autoconf 2.13. So just install autoconf-2.13 and then do the compilation again..

sudo apt-get install autoconf2.13

 

Also if you have a low memory machine, then you might get error such as:

[lots of compile output]
...
/bin/sh /home/ibb_admin/temp/php-5.3.0/libtool --silent --preserve-dup-deps --mode=compile gcc -I/home/ibb_admin/temp/php-5.3.0/ext/fileinfo/libmagic -Iext/fileinfo/ -I/home/ibb_admin/temp/php-5.3.0/ext/fileinfo/ -DPHP_ATOM_INC -I/home/ibb_admin/temp/php-5.3.0/include -I/home/ibb_admin/temp/php-5.3.0/main -I/home/ibb_admin/temp/php-5.3.0 -I/home/ibb_admin/temp/php-5.3.0/ext/date/lib -I/home/ibb_admin/temp/php-5.3.0/ext/ereg/regex -I/usr/include/libxml2 -I/opt/include -I/opt/include/freetype2 -I/usr/include/imap -I/usr/kerberos/include -I/home/ibb_admin/temp/php-5.3.0/ext/mbstring/oniguruma -I/home/ibb_admin/temp/php-5.3.0/ext/mbstring/libmbfl -I/home/ibb_admin/temp/php-5.3.0/ext/mbstring/libmbfl/mbfl -I/opt/include/mysql -I/usr/include/mysql -I/home/ibb_admin/temp/php-5.3.0/ext/sqlite3/libsqlite -I/home/ibb_admin/temp/php-5.3.0/TSRM -I/home/ibb_admin/temp/php-5.3.0/Zend    -I/usr/include -g -O2  -c /home/ibb_admin/temp/php-5.3.0/ext/fileinfo/libmagic/apprentice.c -o ext/fileinfo/libmagic/apprentice.lo
virtual memory exhausted: Cannot allocate memory
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1

So just upgrade the gcc compiler to its latest version and also add –disable-fileinfo to ./configure

Hence full installation procedure would be similar to:

sudo apt-get install autoconf2.13
wget http://us.php.net/get/php-5.3.6.tar.bz2/from/us.php.net/mirror
tar -xjf php-5.3.6.tar.bz2
cd php-5.3.6/
./buildconf --force
./configure --disable-fileinfo --enable-fpm --with-zlib --enable-pdo --with-pdo-mysql --enable-sockets --with-mysql --enable-calendar --with-iconv --enable-exif --enable-soap --enable-ftp --enable-wddx --with-zlib --with-bz2 --with-gettext --with-xmlrpc --enable-pcntl --enable-soap --enable-bcmath --enable-mbstring --enable-dba --with-openssl --with-mhash --with-mcrypt --with-xsl --with-curl --with-pcre-regex --with-gd --enable-gd-native-ttf --with-ldap --enable-pdo --with-pdo-mysql --with-mysql --with-sqlite --with-pdo-sqlite --enable-zip--enable-sqlite-utf8 --with-pear

 

Of course, your php configure options can be different.

If You like the post just put a comment..

  • Testguy

    Good write up. One thing to mention, you don’t necessarily need to install the older version of autoconf to run buildconf. The `vcsclean` script is just looking for a version control directory structure. All I had to do was `mkdir CVS` and buildconf –force would run.

    • http://sahilp.in SAHIL

      but some scripts designed for autoconf 2.13 dont work on newer versions of autoconf so i had to install autoconf 2.13…