LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 03-27-2013, 02:12 AM   #1
rnturn
Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0), SuSE (10.x, 11.x, 12.2), Solaris (8-10), Tru64
Posts: 941

Rep: Reputation: 51
PHP compile error... Can anyone help figure this out?


I have been trying to compile a set of software: Apache httpd 2.4.4, PostgreSQL 9.2.3, and PHP 5.4.12 (I went the "LAPP" route instead of "LAMP"). All the software has compiled EXCEPT for PHP. It's failing with the error message:
Code:
   .
   .
   .
/bin/sh /usr/local/src/php/libtool --silent --preserve-dup-deps --mode=compile /usr/local/src/php/meta_ccld  -Iext/standard/ -I/usr/local/src/php/ext/standard/ -DPHP_ATOM_INC -I/usr/local/src/php/include -I/usr/local/src/php/main -I/usr/local/src/php -I/usr/local/src/php/ext/date/lib -I/usr/local/src/php/ext/ereg/regex -I/usr/include/libxml2 -I/opt/app/include -I/usr/local/src/php/ext/mbstring/oniguruma -I/usr/local/src/php/ext/mbstring/libmbfl -I/usr/local/src/php/ext/mbstring/libmbfl/mbfl -I/opt/app/postgresql-9.2.3/include -I/usr/local/src/php/TSRM -I/usr/local/src/php/Zend  -D_REENTRANT  -I/usr/include -g -O2 -fvisibility=hidden -pthread -DZTS  -c /usr/local/src/php/ext/standard/file.c -o ext/standard/file.lo 
In file included from /opt/app/include/fnmatch.h:38:0,
                 from /usr/local/src/php/ext/standard/file.c:118:
/opt/app/include/ap_config.h:25:17: fatal error: apr.h: No such file or directory
compilation terminated.
make: *** [ext/standard/file.lo] Error 1
and when I go looking for 'apr.h' sure enough, its nowhere to be found. It's definitely not in the /opt/app/include tree where PHP couldn't find it but there is an 'apr.h' under /usr/include/apr-1. I'm not positive that is the missing header file though it does have comments in the top of the file that indicate that it's from the Apache group so ... maybe. Since this, apparently, involves a missing Apache header file, I can't say that this is a PHP error, per se, but it's during the PHP compile where it's dying. (I suspect that any other software that I would compile that tried to use the Apache header files would fail the same way.)

The line near the end of the above error messages shows that the header file 'ap_config.h' was where the 'apr.h' file could not be found. The 'ap_config.h' contains:
Code:
#include "apr.h"       <==<< the line where the PHP build is failing
#include "apr_hooks.h"
#include "apr_optional_hooks.h"
and, if I remember my C (and it's been a while since I've written much of it), the syntax is telling 'cc' to look in the same directory for the file to include (as opposed to '#include <apr.h>' which would go looking for the file to include in the /usr/include tree).

The configure command that I'm using for PHP is:
Code:
./configure \
        --prefix=/opt/app/php \
        --with-apxs2=/opt/app/httpd/bin/apxs \
        --enable-mbstring \
        --enable-gd-native-ttf \
        --with-gd \
        --with-jpeg-dir=/usr/lib \
        --with-pdo-pgsql=/opt/app/postgresql \
        --with-pgsql=/opt/app/postgresql \
        --with-png-dir=/usr/lib \
        --with-xpm-dir=/usr/X11R6/lib \
        --with-zlib=/opt/app \
        --without-mysql \
        --without-pdo-sqlite
The only difference between the above configure command and the one I'm using on another system -- on which, BTW, all of this software compiles without error -- is the location of the apxs binary which seems to have moved from the httpd/sbin directory to httpd/bin when Apache went to 2.2.x -> 2.4.x.

I have previously built Apache 2.2.21 and PHP 5.3.8 and not run into this error and I'm using the same configure options for the 5.3.8 compile as I am for 5.4.12 (except for the location of the axps file). Oddly, the 'apr.h' file is not found on the system (that I haven't upgraded yet) running httpd 2.2.21. But everything has compiled without error on that system.

Has anyone else run into this? Is there a PHP configure option that is forcing the build to go out looking for this header file? Any tips are most welcome.

TIA...

--
Rick
 
Old 03-27-2013, 04:17 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,922

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
Hi,

Note that apache-2.4.x sources come without apr and apr-util. So I guess that when you built apache, you've used some deprecated apr headers (from /usr/include) which the newer php sources do not like.
You can d/l the apr, apr-util sources from apache, extract them inside the srclib of apache-2.4.4 source and rename them to just apr and apr-util (i.e. omit the version numbers). This way you should have the 2 subdirs: httpd-2.4.4/srclib/apr and httpd-2.4.4/srclib/apr-util
Then (re)compile apache adding the "--with-included-apr" option and after finishing try to compile php again and see how it goes

Regards
 
Old 03-27-2013, 11:28 AM   #3
rnturn
Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0), SuSE (10.x, 11.x, 12.2), Solaris (8-10), Tru64
Posts: 941

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by bathory View Post
Note that apache-2.4.x sources come without apr and apr-util. So I guess that when you built apache, you've used some deprecated apr headers (from /usr/include) which the newer php sources do not like.
Ugh.. what the heck are Apache headers doing in /usr/include? (Probably seemed like a good idea to someone at the time.) The contents of /usr/include should be untouched as the system I'm compiling on has only been upgraded (OpenSUSE 12.2) in the last month or so. I did apparently allow Apache to be installed at the time. Could be the source (pun intended) of my woes. Trying to remove it now may be nearly impossible. (If you thought that Windows DLL Hell was no fun... Linux distributions aren't any better, maybe worse.)

Quote:
You can d/l the apr, apr-util sources from apache, extract them inside the srclib of apache-2.4.4 source and rename them to just apr and apr-util (i.e. omit the version numbers). This way you should have the 2 subdirs: httpd-2.4.4/srclib/apr and httpd-2.4.4/srclib/apr-util
Then (re)compile apache adding the "--with-included-apr" option and after finishing try to compile php again and see how it goes
Will do. I'll download those two bundles from Apache and see how it goes. I guess they were broken out as part of the 2.2 -> 2.4 transition. There was likely a note about it on he Apache site that I missed or glossed over.

Thanks for the hint...

--
Rick
 
Old 03-27-2013, 06:18 PM   #4
rnturn
Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0), SuSE (10.x, 11.x, 12.2), Solaris (8-10), Tru64
Posts: 941

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by bathory View Post
Then (re)compile apache adding the "--with-included-apr" option and after finishing try to compile php again and see how it goes
That helped but it was only part of the solution.

When I included the "--with-included-apr" option, it did get a copy of 'apr.h' created in the include directory but it was placed in /opt/app/httpd/include and not /opt/app/include. The PHP compile still failed.

So... I went through all of the "configure" command scripts that I have for all the LAPP components and either added "--includedir=/opt/app/include" or, in the case of httpd, modified the layout script for my layout to point to that directory, and then recompiled pretty much everything: PostgreSQL, httpd, zlib, etc. along with PHP. Then the PHP compile worked.

However...

When I try to start the httpd daemon, it fails with error_log containing a message about "mod_unixd" not being loaded. So it appears that everything I thought knew about compiling httpd is now wrong. I suspect that my configure command will need even more options to make httpd work as it did in 2.2.x. Hopefully, all the changes they've made to the way one build the 2.4.x Apache will be worth the hassle. (Enough seems to have changed that makes you think this ought to have been Apache 3.x.x.)

Back to the manuals... and the docs that are in the httpd source tree or that are installed in the 'manual' subdirectory aren't even HTML. (sigh)

--
Rick
 
Old 03-28-2013, 03:00 AM   #5
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,922

Rep: Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327Reputation: 1327
Quote:
When I included the "--with-included-apr" option, it did get a copy of 'apr.h' created in the include directory but it was placed in /opt/app/httpd/include and not /opt/app/include. The PHP compile still failed.
This is where it's supposed to be installed. If you want, you could compile apr separately and use "--with-apr=..." to compile apache. And of course this has nothing to do with php, as php uses apxs to built as an apache module. You should run
Code:
make distclean
after any failed compiled and before running ./configure again

Quote:
When I try to start the httpd daemon, it fails with error_log containing a message about "mod_unixd" not being loaded. So it appears that everything I thought knew about compiling httpd is now wrong. I suspect that my configure command will need even more options to make httpd work as it did in 2.2.x. Hopefully, all the changes they've made to the way one build the 2.4.x Apache will be worth the hassle. (Enough seems to have changed that makes you think this ought to have been Apache 3.x.x.)
Strange. Again did you run "make distclean" in apache source tree before recompiling apache?
 
Old 03-28-2013, 10:14 AM   #6
rnturn
Member
 
Registered: Jan 2003
Location: Illinois (Chicago area)
Distribution: Red Hat (8.0), SuSE (10.x, 11.x, 12.2), Solaris (8-10), Tru64
Posts: 941

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by bathory View Post
This is where it's supposed to be installed. If you want, you could compile apr separately and use "--with-apr=..." to compile apache. And of course this has nothing to do with php, as php uses apxs to built as an apache module. You should run
Code:
make distclean
after any failed compiled and before running ./configure again


Strange. Again did you run "make distclean" in apache source tree before recompiling apache?
Yeah... 'make distclean' and I are old friends.

I grabbed the latest bundles of 'apr' and 'apr-util', unpacked them in /usr/local/src, created a symbolic links to let me ignore the version, for example,
Code:
ln -s apr-1.2.3 apr
. I then switched to /usr/local/src/httpd/srclib and created symlinks to point back to the apr and apr-util trees:
Code:
ln -s /usr/local/src/apr apr
ln -s /usr/local/src/apr-util apr-util
(My reason for doing it this way is that I'd rather create a couple of symlinks when a new version of httpd comes out that to keep unpacking those two tar archives.) While doing some leisure reading over at the Apache site, I noticed that PCRE was no longer bundled with the httpd code so I grabbed a copy, configured, compiled and installed that. My httpd configure command now looks like:
Code:
./configure \
   --enable-so \
   --enable-layout=optapp \    <==<< (like the "opt" layout but tweaked for "/opt/app")
   --with-included-apr \
   --with-pcre=/opt/app/pcre \
   --enable-unixd
To ensure that PHP was able to find any header files, I change the configure commands for all the LAPP components to point to /opt/app/include using
Code:
  --includedir=/opt/app/include
and recompiled. PHP was then able to find that missing 'apr.h' file.

The 'mod_unixd' error, was addressed using the '--enable-unixd' line in the configure command for httpd shown above.

And last, but far from least, I renamed the configuration file directory for httpd and created a new, empty directory prior to running 'make install''' for httpd. That step doesn't overwrite any existing configuration files. Doesn't sound so bad except that V2.4.x doesn't seem to like the V2.2.x configuration files so letting the installation create new ones and later tweaking those worked.

Now to update my documentation so I won't forget this stuff when the time to upgrade comes again. Number one paragraph: Make sure you read the release notes to see how much has changed. That would have gotten me farther down road toward solving the 'missing apr.h' problem. The 'includedir' part took a little more head scratching and more recompilation than I expected but not a huge problem.

Thanks for the pointer on the missing software pieces.

Later...

--
Rick
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can not install/compile PHP on 64bit RHEL 6.3 : Error configure: error: utf8_mime2tex sanjivus Red Hat 1 12-26-2012 04:24 PM
Conmpile error wen compile php:configure: error: libpng.(a|so) not found tanveer Linux - Software 5 02-03-2009 06:13 AM
PHP Compile Error blong4life Linux - Software 1 02-18-2008 08:59 AM
PHP compile error... mpbraj Linux - Server 2 12-23-2006 12:05 AM
PHP Compile error hampen Linux - Software 6 04-29-2006 05:34 PM


All times are GMT -5. The time now is 07:20 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration