Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

7 Answers

up vote 92 down vote accepted

You're on Ubuntu so try: apache2ctl -M

share|improve this answer
5  
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
2  
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
    
sudo apache2ctl -M | sort –  mmdemirbas Jul 6 '12 at 13:30
add comment

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

share|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
2  
@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 '12 at 9:13
1  
Apache is httpd on redhat. Try one of the other answers if this one doesn't work for you. –  Jacks_Depression Jan 14 '13 at 15:46
add comment

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.

share|improve this answer
add comment

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
share|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
add comment

You can also use apachectl

apachectl -t -D DUMP_MODULES
share|improve this answer
add comment

If you are on Redhat/CentOS, httpd is used in place of apache2ctl.

This means you need to use the

httpd -M

However, httpd is almost never in the path you expect.

I can confirm on CentOS 5.8 the actual path is /usr/sbin/httpd.

/usr/sbin/httpd -M

But if that is not the path, you can discover it. Here is how I was able to do so.

First, I checked the daemon being used to control it.

less /init.d/httpd

Around line 40ish

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/sbin/apachectl
httpd=${HTTPD-/usr/sbin/httpd}
prog=httpd

Which told me exactly where to find it. Hope this helps.

share|improve this answer
add comment

On my gentoo, I can execute apache2ctl modules and see the modules listed.

share|improve this answer
add comment

Your Answer

 
discard

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.