Trouble Shooting

If you get a message like this:

     Starting httpd: Syntax error on line 239 of /etc/httpd/conf/httpd.conf:
     API module structure `php5_module' in file
       /usr/share/httpd-m.n/modules/libphp5.so is garbled - perhaps this is not
       an Apache module DSO?

When you try to start Apache with PHP, it is probably due to the fact that the version of PHP that you are trying to run was not compiled against the version of httpd that you are starting.

The first thing to check is that the ./configure line used to build PHP has the proper --with-apxs2=/usr/share/httpd-m.n/bin/apxs parameter (i.e. that it points to the correct apxs file for the version of Apache that you're trying to run). If not, rebuild PHP correctly.

If PHP was built with the correct apxs file, you are probably running an older version of Apache that was left lying around on your system. Be advised that those swell folks at RedHat will install a bogus copy of httpd, probably in /usr/sbin, even if you tell them not to install the Apache rpm when you build the system. Its just a little service that they like to supply you with. If that's the case, the copy of apachectl that they also installed when you asked them not to, probably in /usr/sbin as well, is undoubtedly running the old httpd when it gets started by the httpd script, in /etc/rc.d/init.d, that wasn't supposed to be installed either.

To repair the problem caused by an older version of httpd, you can either update /etc/rc.d/init.d/httpd (if you decide to keep the older startup script) or possibly delete the old modules and symlink the old names to the new, correct ones.

Updating the httpd startup script will allow you to go back to a previous version of Apache, if you change you mind. To do this, alter the following variables, possibly as shown in this example:

     apachectl=/usr/share/httpd-m.n/bin/apachectl
     httpd="/usr/share/httpd-m.n/bin/httpd -f /etc/httpd/conf/httpd-m.n.xx.conf"

Once you are sure that everything works, you may want to delete the older versions of httpd and apachectl to ensure that they aren't ever run by mistake:

     rm -f /usr/sbin/httpd /usr/sbin/httpd.worker
     rm -f /usr/sbin/apachectl

Symlinking the older names to the newer names will ensure that: 1) the older versions are never run by mistake; 2) their names are kept in their original locations so that they can always be easily found. Do something like this:

     rm -f /usr/sbin/httpd
     ln -s /usr/share/httpd-m.n/bin/httpd /usr/sbin/httpd
     rm -f /usr/sbin/httpd.worker  (this is a bogus, threaded version, installed
                                   by our pals at RedHat)
     rm -f /usr/sbin/apachectl
     ln -s /usr/share/httpd-m.n/bin/apachectl /usr/sbin/apachectl

If you still cannot find the problem, there is a possibility that httpd was linked against different dynamic libraries that PHP. To determine whether this is the case, try the following commands:

     ldd /usr/share/httpd-m.n/modules/libphp5.so
     ldd /usr/share/httpd-m.n/bin/httpd

Compare the output from both of these commands and look to see if either of the modules links to a different dynamic library. If it does, correct the environment variables and/or specify the linkage paths via configure so that both modules are reading from the same page. For standard system libaries, usually rebuilding both modules at the same time (i.e. with the same environment variables) will fix the problem while for the more esoteric libraries supplying the identical libary paths to both the Apache and PHP ./configure commands will fix the problem.