views:

41

answers:

1

I am pretty new to Linux. Got a VPS set up yesterday, installed Apache2, PHP5 and MySQL.

When I do apache2 -l I get this:

Compiled in modules:
  core.c
  mod_log_config.c
  mod_logio.c
  prefork.c
  http_core.c
  mod_so.c

When I do sudo a2enmod rewrite I get this:

Module rewrite already enabled

And rewrite.load is in /etc/apache2/mods-enabled.

Can anyone tell what's wrong?

+1  A: 

This really belongs on ServerFault, but since it'll probably get migrated eventually I'll go ahead and say that there's a difference between modules that are compiled into Apache and modules that are dynamically loaded.

Apache is able to load modules in two different ways. The "simpler" way is for the module to be statically compiled into the server. This means that the executable file apache2 literally includes the module's code. The advantage of this approach is that the module is always available and Apache doesn't have to do anything special to get access to its code, but on the other hand, if you want to add, remove, or update a statically compiled module, you have to recompile all of Apache. Plus, the more modules that are statically compiled, the bigger the executable file becomes. For these reasons, it's normal for that list to only include a few of the most essential modules, basically the minimum necessary for Apache to run. Those few modules are the ones that appear in the list you see when you run apache2 -l.

All the other modules that Apache uses, including mod_rewrite, are dynamically loaded. That is, their code is stored as separate files, which Apache locates and reads in after it's started up. This negates the disadvantages of the static compilation approach: since the modules are stored in separate files, if you want to add/remove/change one, you only need to restart the server, not recompile it. You can tell Apache which modules to load by putting LoadModule directives in your Apache configuration file. This is basically what a2enmod does: it adds a LoadModule directive to the configuration file. (Actually it symlinks a stub configuration file into a directory that is sourced by the main configuration)

If you want to see a complete list of loaded modules, including the dynamically loaded ones, you can run

apache2 -M

You'll have to make sure to run Apache in the same way as Ubuntu's init script, though. It's common for the system to read in a configuration file or something before it starts Apache up, and if you don't do the same, it might change the set of modules that gets loaded.

David Zaslavsky