How to fix "/www/bin/apxs: No such file or directory"

The other day I was trying to compile php in one of my Linux machine and this error threw up. Well then I thought let me provide a solution for this on my blog as well.
 

Error

This error comes when you are trying to compile php with Apache.

# ./configure --with-apxs=/www/bin/apxs

Well I was following the INSTALL directory present inside the downloaded php directory which told me to compile using the above syntax if I wanted to integrate my php with Apache. Initially I didn't recognised that the path I was using for apxs was not correct but anyhow we will come to know about it once we run the command.
 

Solution

This happens because of the following missing package

  • httpd
  • httpd-devel (important)

In most cases httpd-devel package is missing which leads to this error.
On Red Hat, Fedora, CentOS

# yum install httpd httpd-devel

Once the package is installed look out for apxs in your machine

# which apxs
/usr/sbin/apxs

So as you see the location of apxs is different as we were using in our command. Now try to compile your PHP

# ./configure --with-apxs=/www/bin/apxs

NOTE: If your Apache version is higher than 1.3 then you will have to use apxs2 instaed of apxs.

# ./configure --with-apxs2=/www/bin/apxs

I hope the article was useful.