PHP: Build Problems - Manual
PHP  
downloads | documentation | faq | getting help | | php.net sites | links 
search for in the  
previousInstallationUsing PHPnext
Last updated: Wed, 24 Jul 2002
view this page in Printer friendly version | English | Brazilian Portuguese | Czech | Dutch | Finnish | French | German | Hungarian | Italian | Japanese | Korean | Polish | Romanian | Russian | Spanish | Turkish

�� 50. Build Problems

This section gathers most common errors that occur at build time.

1. I got the latest version of PHP using the anonymous CVS service, but there's no configure script!
2. I'm having problems configuring PHP to work with Apache. It says it can't find httpd.h, but it's right where I said it is!
3. When I run configure, it says that it can't find the include files or library for GD, gdbm, or some other package!
4. When it is compiling the file language-parser.tab.c, it gives me errors that say yytname undeclared.
5. When I run make, it seems to run fine but then fails when it tries to link the final application complaining that it can't find some files.
6. When linking PHP, it complains about a number of undefined references.
7. I can't figure out how to build PHP with Apache 1.3.
8. I have followed all the steps to install the Apache module version on UNIX, and my PHP scripts show up in my browser or I am being asked to save the file.
9. It says to use: --activate-module=src/modules/php4/libphp4.a, but that file doesn't exist, so I changed it to --activate-module=src/modules/php4/libmodphp4.a and it doesn't work!? What's going on?
10. When I try to build Apache with PHP as a static module using --activate-module=src/modules/php4/libphp4.a it tells me that my compiler is not ANSI compliant.
11. When I try to build PHP using --with-apxs I get strange error messages.
12. During make, I get errors in microtime, and a lot of RUSAGE_ stuff.
13. I want to upgrade my PHP. Where can I find the ./configure line that was used to build my current PHP installation?
14. When building PHP with the GD library it either gives strange compile errors or segfaults on execution.

1. I got the latest version of PHP using the anonymous CVS service, but there's no configure script!

You have to have the GNU autoconf package installed so you can generate the configure script from configure.in. Just run ./buildconf in the top-level directory after getting the sources from the CVS server. (Also, unless you run configure with the --enable-maintainer-mode option, the configure script will not automatically get rebuilt when the configure.in file is updated, so you should make sure to do that manually when you notice configure.in has changed. One symptom of this is finding things like @VARIABLE@ in your Makefile after configure or config.status is run.)

2. I'm having problems configuring PHP to work with Apache. It says it can't find httpd.h, but it's right where I said it is!

You need to tell the configure/setup script the location of the top-level of your Apache source tree. This means that you want to specify --with-apache=/path/to/apache and not --with-apache=/path/to/apache/src.

3. When I run configure, it says that it can't find the include files or library for GD, gdbm, or some other package!

You can make the configure script looks for header files and libraries in non-standard locations by specifying additional flags to pass to the C preprocessor and linker, such as:
CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure
If you're using a csh-variant for your login shell (why?), it would be:
env CPPFLAGS=-I/path/to/include LDFLAGS=-L/path/to/library ./configure

4. When it is compiling the file language-parser.tab.c, it gives me errors that say yytname undeclared.

You need to update your version of Bison. You can find the latest version at .

5. When I run make, it seems to run fine but then fails when it tries to link the final application complaining that it can't find some files.

Some old versions of make that don't correctly put the compiled versions of the files in the functions directory into that same directory. Try running cp *.o functions and then re-running make to see if that helps. If it does, you should really upgrade to a recent version of GNU make.

6. When linking PHP, it complains about a number of undefined references.

Take a look at the link line and make sure that all of the appropriate libraries are being included at the end. Common ones that you might have missed are '-ldl' and any libraries required for any database support you included.

If you're linking with Apache 1.2.x, did you remember to add the appropriate information to the EXTRA_LIBS line of the Configuration file and re-rerun Apache's Configure script? See the file that comes with the distribution for more information.

Some people have also reported that they had to add '-ldl' immediately following libphp4.a when linking with Apache.

7. I can't figure out how to build PHP with Apache 1.3.

This is actually quite easy. Follow these steps carefully:

  • Grab the latest Apache 1.3 distribution from .

  • Ungzip and untar it somewhere, for example /usr/local/src/apache-1.3.

  • Compile PHP by first running ./configure --with-apache=/<path>/apache-1.3 (substitute <path> for the actual path to your apache-1.3 directory.

  • Type make followed by make install to build PHP and copy the necessary files to the Apache distribution tree.

  • Change directories into to your /<path>/apache-1.3/src directory and edit the Configuration file. Add to the file: AddModule modules/php4/libphp4.a.

  • Type: ./Configure followed by make.

  • You should now have a PHP-enabled httpd binary!

Note: You can also use the new Apache ./configure script. See the instructions in the README.configure file which is part of your Apache distribution. Also have a look at the INSTALL file in the PHP distribution.

8. I have followed all the steps to install the Apache module version on UNIX, and my PHP scripts show up in my browser or I am being asked to save the file.

This means that the PHP module is not getting invoked for some reason. Three things to check before asking for further help:

  • Make sure that the httpd binary you are running is the actual new httpd binary you just built. To do this, try running: /path/to/binary/httpd -l

    If you don't see mod_php4.c listed then you are not running the right binary. Find and install the correct binary.

  • Make sure you have added the correct Mime Type to one of your Apache .conf files. It should be: AddType application/x-httpd-php3 .php3 (for PHP 3)

    or AddType application/x-httpd-php .php (for PHP 4)

    Also make sure that this AddType line is not hidden away inside a <Virtualhost> or <Directory> block which would prevent it from applying to the location of your test script.

  • Finally, the default location of the Apache configuration files changed between Apache 1.2 and Apache 1.3. You should check to make sure that the configuration file you are adding the AddType line to is actually being read. You can put an obvious syntax error into your httpd.conf file or some other obvious change that will tell you if the file is being read correctly.

9. It says to use: --activate-module=src/modules/php4/libphp4.a, but that file doesn't exist, so I changed it to --activate-module=src/modules/php4/libmodphp4.a and it doesn't work!? What's going on?

Note that the libphp4.a file is not supposed to exist. The apache process will create it!

10. When I try to build Apache with PHP as a static module using --activate-module=src/modules/php4/libphp4.a it tells me that my compiler is not ANSI compliant.

This is a misleading error message from Apache that has been fixed in more recent versions.

11. When I try to build PHP using --with-apxs I get strange error messages.

There are three things to check here. First, for some reason when Apache builds the apxs Perl script, it sometimes ends up getting built without the proper compiler and flags variables. Find your apxs script (try the command which apxs, it's sometimes found in /usr/local/apache/bin/apxs or /usr/sbin/apxs. Open it and check for lines similar to these:
my $CFG_CFLAGS_SHLIB  = ' ';          # substituted via Makefile.tmpl
my $CFG_LD_SHLIB      = ' ';          # substituted via Makefile.tmpl
my $CFG_LDFLAGS_SHLIB = ' ';          # substituted via Makefile.tmpl
If this is what you see, you have found your problem. They may contain just spaces or other incorrect values, such as 'q()'. Change these lines to say:
my $CFG_CFLAGS_SHLIB  = '-fpic -DSHARED_MODULE'; # substituted via Makefile.tmpl
my $CFG_LD_SHLIB      = 'gcc';                   # substituted via Makefile.tmpl
my $CFG_LDFLAGS_SHLIB = q(-shared);              # substituted via Makefile.tmpl
The second possible problem should only be an issue on Red Hat 6.1 and 6.2. The apxs script Red Hat ships is broken. Look for this line:
my $CFG_LIBEXECDIR    = 'modules';         # substituted via APACI install
If you see the above line, change it to this:
my $CFG_LIBEXECDIR    = '/usr/lib/apache'; # substituted via APACI install
Last, if you reconfigure/reinstall Apache, add a make clean to the process after ./configure and before make.

12. During make, I get errors in microtime, and a lot of RUSAGE_ stuff.

During the make portion of installation, if you encounter problems that look similar to this:
microtime.c: In function `php_if_getrusage':
microtime.c:94: storage size of `usg' isn't known
microtime.c:97: `RUSAGE_SELF' undeclared (first use in this function)
microtime.c:97: (Each undeclared identifier is reported only once
microtime.c:97: for each function it appears in.)
microtime.c:103: `RUSAGE_CHILDREN' undeclared (first use in this function)
make[3]: *** [microtime.lo] Error 1
make[3]: Leaving directory `/home/master/php-4.0.1/ext/standard'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/master/php-4.0.1/ext/standard'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/master/php-4.0.1/ext'
make: *** [all-recursive] Error 1

Your system is broken. You need to fix your /usr/include files by installing a glibc-devel package that matches your glibc. This has absolutely nothing to do with PHP. To prove this to yourself, try this simple test:
$ cat >test.c <<X
#include <sys/resource.h>
X
$ gcc -E test.c >/dev/null
If that spews out errors, you know your include files are messed up.

13. I want to upgrade my PHP. Where can I find the ./configure line that was used to build my current PHP installation?

Either you look at config.nice file, in the source tree of your current PHP installation or, if this is not available, you simply run a
<?php phpinfo(); ?>
script. On top of the output the ./configure line, that was used to build this PHP installation is shown.

14. When building PHP with the GD library it either gives strange compile errors or segfaults on execution.

Make sure your GD library and PHP are linked against the same depending libraries (e.g. libpng).

User Contributed Notes
Build Problems
add a note about notes

14-Oct-2001 07:43

Defining the right environment variables for my Apache "make"
invocation allowed the correct "apxs" file to be generated for
me.  Your mileage may vary.

cd ../apache_1.3.22
CFLAGS_SHLIB="-fpic -DSHARED_MODULE" \
  LD_SHLIB=gcc \
  LDFLAGS_MOD_SHLIB="-shared" \
  make


23-Jan-2002 12:49

Concerning question 12(broken includes etc.) :
i found that in my case HAVE_SYS_RESOURCE_H wasn't defined in microtime.c,
so sys/resource.h wasn't included. After commenting out the #ifdef
HAVE_SYS_RESOURCE_H (and the corresponding #endif of cause) everything
worked fine.
I think something went wrong during configure, but i couln't find out
what.
Regards, 
Lukas


26-Jan-2002 01:21

Lukas's solution worked for me, as well - Slackware 7.0, gcc version 2.95.3
20010315, glibc 2.1.2


28-Feb-2002 06:28

The advice here that there must be something wrong with glibc should _not_
suggest to you that you want to go grab the latest glibc tar from GNU and
install it. That breaks gcc, and then if you grab the latest gcc from GNU
and try to install it, well, it just may not work (after taking hours to
almost finish building). Frankly, my glibc had always worked fine
including with prior versions of PHP 4, but that microtime thing did bite,
and I did believe the kind writer of this page who claimed there must be
something wrong on my system. (If only GNU had just a bit better quality
control on what _they're_ putting out, this wouldn't have been such a
waste.) Ah, now to restore from backup.


28-Feb-2002 07:15

Lukas's solution also works for Red Hat 6.0 with kernel 2.4.16, gcc version
2.7.2.3 or 2.95.3 and glibc 2.1.3-15. Evidently the PHP configuration
routine failes to define HAVE_SYS_RESOURCE_H on a variety of systems.


27-Mar-2002 10:04

I have needed to referer to this page several times during my recent 4.1.2
compiles, and I noticed one thing in point 13 that is missing.  If you
need to find out what ./configure script was used to compile your present
php version, simply echo out phpinfo().   I  keep a phpinfo.php page on
each of my  webservers for refrence.  

<?php echo phpinfo(); ?>

An additional note for PHP shell scripters: I also have a
phpinfo_shell.php that does the same for my "shell version" of
php (/usr/bin/php): 

<?php  echo `echo "<?php echo phpinfo(); ?>" |
/usr/bin/php -q`; ?>

it looks a bit funny, but it works great! =)


29-Jun-2002 12:12

I too had the same problem with q.12. Using Slackware 7.1, upgraded to
2.4.18 kernel (all required upgrades added as per kernel Changes docs).
Nothing was mentioned about glibc and I doubt Pat V got it wrong with
Slack 7.1. I've built many versions of PHP since moving to the 2.4 kernel
so why now would it all go wrong? Anyway, have commented code out as per
Lucas's post to see what happens.


30-Jun-2002 01:53

NEED HELP
i have the same probleme like the FAQ2 " I'm having problems
configuring PHP to work with Apache. It says it can't find httpd.h, but
it's right where I said it is! "
i am working on solaris 8 (sparc). The location of the top-level of my
Apache source tree is /usr/apache, i ve tried
"...--with-apache=/usr/apache" and
"...with-apache=/usr", it doesn't work both this example

thx for help


09-Jul-2002 10:18

i am getting the error
fatal error: failed opening required '
(include_path='.;c:\php4\pear') in 
on line 19 while working with phpshop downloaded from sourceforge.net


09-Jul-2002 05:25

Wow this page has been a big help, but I'm still having problems. Here is
my rundown:
RedHat 6.1, Kernel 2.4.18, Apache 2.0.39, attempting PHP 3.0.18. I gave up
on version 4.

I was having problems regarding #12, took out the #ifdef and included
resource.h. I still get warnings regarding microtime.c AND posix.c

Says /usr/include/bits/resource.h warning 'RLM_INFINITY' redefined
/usr/include/asm/resource.h this is the location of previous function
?????????????
It continues to compile, then errors out with an undefined reference to
un_compress and compress from libmysqlclient.a(my_compress.o)
I believe I'm missing some mysql files. I am checking now. This is my
first time I've needed PHP and it is driving me nutz. Sorry for the long
post, but any help would be greatly apprciated. (even a good list to get
on would help!)
Thanks.


10-Jul-2002 05:11

Resolved my previous issue. configured php using --with-zlib and it got
past THAT problem. I switched back to PHP 4.2.1 and got further along. Now
have problems on the make install. 

[install-sapi] error1
[install-recursive] error 1

My make ran fine! I did have to comment out the #ifdef section of
php_function.c to get it to work. *sigh*


10-Jul-2002 11:11

PHP 4.2.1 and Apache 2.0.39 to work 

Finally! Wow, let me see if I can get this right. Here is what I did:

1) Downloaded and installed the following:
	Latest STABLE php from snaps.php.net (dated 7/10/02 9 AM)
	pth-1.4.1.tar.gz from ftp.gnu.org/gnu/pth/ (this 'may' have helped!)
	
2) reconfigured, apache using:
	 ./configure --prefix=/path/to/apache --with-module=so
	make clean, make, make install
	(NOTE: I don't think this was needed, but I wanted clean! Also didn't
start it yet.)

3) installed the new STABLE php 4.2.1 and made some changes:
	In 'path to php'/ext/standard commented out in microtime.c line 31 
	"#ifedf HAVE_SYS_RESOURCE_H" to "/* #ifedf
HAVE_SYS_RESOURCE_H */"  NO quotes!
	and also line 33
	"#endif" to "/* #endif */" No Quotes!
	I don't know what the problem was. I knew it needed the include on line
32.
	so this just puts the darn thing in!
	The previous problems in php_functions.c seemed to be fixed, so no change
there.

4) config php:
	run 'make distclean'
	./configure --with-mysql --with-zlib
--with-apxs2=/usr/local/apache/bin/apxs
	Note: /usr/local/apache is my path! Yours could be
/I/like/grandma/bin/apxs!
	make clean, make 
	NOTE: I get like 6 warnings about RLIM_INFINITY being redefined during
the make.
	I believe it has to do with different versions of my resource.h.
	I think this is due to uprading my kernel. Not to worry if you get this.
	It is just a warning. Has to do with the declaration of the size of it I
think.
	make install

5) back to /usr/local/apache/conf and edit httpd.conf
	make sure that 'AddType application/x-httpd-php .php' is there
	IT WASN'T! Rumor says it auto places it. HEH!
	Also make sure 'LoadModule php4_module	modules/libphp4.so' is there.
	It was. Huh??? Oh well.
	apachectl start 
	a edit quick helloworld.php
	open fav web browser, bang! 
	Scream Haleluyah while dancing a jig! People in office look at you funny.
	
Man I hope I save someone some time!

add a note about notes
previousInstallationUsing PHPnext
Last updated: Wed, 24 Jul 2002
show source | credits | stats | mirror sites:  
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by:
Last updated: Sun Jul 28 16:09:02 2002 CEST