Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just setup a new server which will host a solr daemon. As it stands now the solr index is empty, but I have a php script available to pull data from a MySQL store and populate the solr index to facilitate my fulltext searching requirements.

So I'm wondering, is it possible to compile PHP to be command line only? It seems a waste to have to install apache just to get PHP to work.

-- Edit --

A little more clarification. When I run make install on CentOS, the make attempts to add PHP footprint to /etc/httpd/conf. Is it ok to simply ignore this? Or is there a flag I can pass to ignore apache?

share|improve this question
up vote 1 down vote accepted

If you must compile on Red Hat, CentOS or other Red Hat-derivatives, I recommend you use rpmbuild -bb (I'll explain in the moment) with the provided in the php source either by Red Hat or by upstream developer (PHP). Here is a sample from the upstream:

%define version @VERSION@
%define so_version 5
%define release 0

Name: php
Summary: PHP: Hypertext Preprocessor
Group: Development/Languages
Version: %{version}
Release: %{release}
Copyright: The PHP license (see "LICENSE" file included in distribution)
Icon: php.gif
Packager: PHP Group <>

BuildRoot: /var/tmp/php-%{version}

PHP is an HTML-embedded scripting language. Much of its syntax is
borrowed from C, Java and Perl with a couple of unique PHP-specific
features thrown in. The goal of the language is to allow web
developers to write dynamically generated pages quickly.



set -x
./configure --prefix=/usr --with-apxs \
    --disable-debug \
    --with-xml=shared \

# figure out configure options options based on what packages are installed
# to override, use the OVERRIDE_OPTIONS environment variable.  To add
# extra options, use the OPTIONS environment variable.

#test rpm -q MySQL-devel >&/dev/null && OPTIONS="$OPTIONS --with-mysql=shared"
#test rpm -q solid-devel >&/dev/null && OPTIONS="$OPTIONS --with-solid=shared,/home/solid"
#test rpm -q postgresql-devel >&/dev/null && OPTIONS="$OPTIONS --with-pgsql=shared"
test rpm -q expat >&/dev/null && OPTIONS="$OPTIONS --with-xml=shared"

if test "x$OVERRIDE_OPTIONS" = "x"; then
    ./configure --prefix=/usr --with-apxs=$APXS $OPTIONS
    ./configure $OVERRIDE_OPTIONS

See where it says "--with-apxs"? That is part of development interfaces for the Apache HTTP server. If that is not installed, you will get when running configure (and I believe that is what you are seeing):

Configuring SAPI modules
checking for AOLserver support... no
checking for Apache 1.x module support via DSO through APXS... 

Sorry, I was not able to successfully run APXS.  Possible reasons:

1.  Perl is not installed;
2.  Apache was not compiled with DSO support (--enable-module=so);
3.  'apxs' is not in your path.  Try to use --with-apxs=/path/to/apxs
The output of apxs follows
./configure: line 4092: apxs: command not found
configure: error: Aborting

To compile without apxs support (and thus avoiding the need for apache), you would change that to:


And it will get that pass that point.

Now back to building with a spec file. if you build it with a spec file, rpmbuild will tell you what dependencies you need that will allow you to install. And from there, it will build a package for you and you can install it with:

yum localinstall php.rpm

Which will then allow you to install as well as satisfy the other requirements. That will save you lot of grief by managing your system properly with a packaging system rather than trying to build and install manually.

(or you can follow embobo's advice and install just php-cli ;) ).

share|improve this answer
Outstanding. Thanks for the response. Will give it a whirl. – Mike Purcell Dec 23 '11 at 3:39
Your suggestion about --without-apxs worked. As I am a minimalist, I opted to go a diff route after testing your solution, I added --disable-all then added all the packages I wanted and that worked as well. Thanks again. – Mike Purcell Dec 23 '11 at 6:33

Why are you compiling php manually? Install php-cli and not php (which is the apache module) with yum.

share|improve this answer
Unfortunately the version of PHP available via the default yum repo is 5.3.3, I'm compiling 5.3.8. – Mike Purcell Dec 23 '11 at 3:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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