which is the most elegant way to check which apache modules are enabled?

link|improve this question

feedback

4 Answers

up vote 5 down vote accepted

You're on Ubuntu so try: apache2 -M or apache2ctl -M

link|improve this answer
1  
apache2ctl -M works great – udo May 17 '11 at 20:06
1  
apache2 -M results in this error apache2: bad user name ${APACHE_RUN_USER} – udo May 17 '11 at 20:07
1  
Fair enough - it's due to the fact that you are not running the command as the apache run time user (probably www-data) defined in the apache config. There is a way to fix this but you might as well stick to apache2ctl. – Linker3000 May 17 '11 at 20:23
feedback

httpd -M will tell you which modules are built-in or shared.

link|improve this answer
hmm... I'm getting a "bash: httpd: command not found" when launching httpd -M as root – udo May 17 '11 at 19:58
So then specify the full path to the httpd executable. – Ignacio Vazquez-Abrams May 17 '11 at 19:59
@IgnacioVazquez-Abrams: On Ubuntu (and other Debian based distributions), the name is apache2 and not httpd, which is why it is not found. – Daniel Andersson Apr 11 at 9:13
feedback

Found answer on the interwebs so for anyone still looking.

Nothing from above answers works if you can't run commands on remote server. If you have only "user" privileges or none at all try creating test.php script:

    <pre>
    <?php
    print_r(apache_get_modules());
    ?>
    </pre>

Though it will work only if PHP is installed as mod_php.

link|improve this answer
feedback

I think there are actually three questions here. I'm not sure which you're asking.

  • What modules do you have on disk. What are all the modules you can use.

This would be (usually) in the modules directory of your apache distribution, usually /etc/httpd/modules/

  • What modules is any specific instance configured to run.

This can be checked with /usr/sbin/httpd -M, at least for the base system apache. If you want to check on a specific config file /usr/sbin/httpd -M -f /path/to/config/file

  • What's in a running apache

To get a lot of info, you can see it with http://machinename/server-info/ This isn't configured by default, you'd have to configure it in. Its a bit of an info leak, so configure it so only local people can see it.

If you're on the machine and you have access to be the running user, you can also see what's loaded by checking the process. You can find the parent process with:

ps -ef | gawk '/httpd/ && $3 == 1{print $2}'

Then check out

cat /proc/PID_FROM_ABOVE/maps
link|improve this answer
Useful info but because the OP is using Ubuntu, the file names and locations are different - for example: /usr/sbin/apache2 instead of httpd, and ps -ef | gawk '/apache2/ && $3 == 1{print $2}' The location of the modules is handled differently, with mods-available and mods-enabled subfolders – Linker3000 May 17 '11 at 21:40
Thanks @Linker3000... You're right, this is for RedHat/Centos, I'll let your comment stand on how to convert to Ubuntu – Rich Homolka May 20 '11 at 17:03
feedback

Your Answer

 
or
required, but never shown

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