I am receiving this message:

configure: error: Invalid Apache directory - unable to find httpd.h under /usr/lib64/httpd/

after executing the following command:

./configure --with-apache=/usr/lib64/httpd/

I don't know where is the top-level DIR on my already installed apache. The apache service is already installed on my CentOS 6.5 server from repository using yum install httpd.

  • Apache version 2.2.15-31
  • PHP version 5.4.25

This is the final solution for my question:

Installing httpd-devel package from repository yum install httpd-devel, where the headers of the apache are included.

Configuring php with apxs2: ./configure --with-apxs.

And last step is adding the following lines in the VirtualHost in the httpd.conf file (or in the included .conf files):

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
  • Not sure you needed httpd-devel package but if it's working, that's cool :) (set your own response as accepted so future viewers will have the answer) – Pierre-Yves Gillier Sep 19 '14 at 8:44
  • @Pierre-YvesGillier yum install httpd doesn't install apxs. It's only installed by yum install httpd-devel. So httpd-devel is needed. – TachyonVortex Jan 20 '15 at 16:37

If your apache is already built and configured, you should compile PHP as a shared module instead of a static one.

Overhead is slightly superior but you'll be able to upgrade each component separately.

Configure example:

$ ./configure --with-apxs=<path to apxs binary in apache/http bindir>

Forgot one thing : your apache has to be compiled with mod_so enabled to use dynamic modules built with apxs

  • He doesn't have apxs, he don't have even apache headers... – peterh - Reinstate Monica Sep 18 '14 at 14:23
  • 1
    @PeterHorvath apxs is already installed on my server and httpd-devel packages is installed... – ibedelovski Sep 18 '14 at 14:27
  • If apache is installed and running, apxs has to be there too, else there is a major problem. It's a binary built at same time as httpd. – Pierre-Yves Gillier Sep 18 '14 at 14:31
  • @bedel7 Ok, I extended my answer so. – peterh - Reinstate Monica Sep 18 '14 at 14:36
  • 1
    Nope, apxs is used to build external modules for apache :) You build your apache with mod_so then you build modules with apxs and, finally, add them to apache with LoadModule command – Pierre-Yves Gillier Sep 18 '14 at 14:39

If you want to compile things for apache - this time, php -, you need to have the headers of the apache to do that. They are some like "apache-dev" or "apache2-devel" or "libapache2-devel", or similar named package. This package you have to install.

This development package will contain the apxs binary, which will be probably automatically found by the php configuration scripts.

EXTENSION: Second, read the ./configure --help output of the php source code carefully. As I can remember, as if the were some difference between the --with-apache, --with-apache2 or --with-apxs flags. Are you sure you won't compile for apache1 accidentally?

EXTENSION #2: Maybe you could get the source php package of your distribution as well, at least to find out, how does this the (re)compilation.

  • @PeterSmith I am supposing that --with-apache and --with-apache2 is meaning the apache version (1.x.x or 2.x.x). Right? – ibedelovski Sep 18 '14 at 14:41
  • @bedel7 Yes. Read the configure script output carefully. – peterh - Reinstate Monica Sep 18 '14 at 14:42
  • @PeterSmith weird, configure: WARNING: unrecognized options: --with-apache2. There aren't any entry for --with-apach2... – ibedelovski Sep 18 '14 at 14:44
  • @bedel7 I write third time: read the configure output carefully. You won't get a fourth. And if you are satisfied with an answer, you had to accept/upvote that. – peterh - Reinstate Monica Sep 18 '14 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.