3

I am running apache v2.4 on Ubuntu 14.04 and have containers/directives this format

<IfModule mpm_prefork_module>
        # ...
</IfModule>

However I often see modules referenced in apache official documentation and in stackexchange sites this way:

<IfModule prefork.c>
        # ...
</IfModule>

Ive searched alot, including here - http://httpd.apache.org/docs/2.4/mod/core.html#ifmodule and Im unable to find what the difference is and when one is supposed to be used over the other?


Take the rewrite module for example

From the apache documentation: ifmodule directive

The module argument can be either the module identifier or the file name of the module, at the time it was compiled.
For example, rewrite_module is the identifier and mod_rewrite.c is the file name.

And its very common to see this in .htaccess files

<IfModule mod_rewrite.c>
    # ....
</IfModule>

Ive grep'ed my /etc/apache2 directory and "mod_rewrite.c" isn't defined anywhere.

On my machine the file /etc/apache2/mods-available/rewrite.load
contains:

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

so is mod_rewrite.c a reference to a windows/other file? in which case referring to it on a linux machine would be incorrect syntax?

3
  • 1
    The page you link to clearly shows the difference in the two schemes: One is the module identifier, the other is the source file name that the module was compiled from. Commented Feb 25, 2015 at 5:36
  • @DanielLawson, you've pointed out the difference between the module identifier and the source file name. My question is: What is the difference between apache modules with and without the “.c” extension?, thanks Commented Feb 25, 2015 at 6:19
  • I have elaborated further in an answer below Commented Feb 25, 2015 at 8:00

2 Answers 2

6

In the page you linked to, it contains this text:

The module argument can be either the module identifier or the file name of the module, at the time it was compiled. For example, rewrite_module is the identifier and mod_rewrite.c is the file name. If a module consists of several source files, use the name of the file containing the string STANDARD20_MODULE_STUFF.

Using the example provided, the rewrite module can either be referred to as 'rewrite_module' (identifier) or mod_rewrite.c (filename). Both are equivalent, and there is no difference. You can use either.

The module with the source file mod_rewrite.c, gets compiled into mod_rewrite.so, which is what you'll have on your filesystem. This source file has the line 'module AP_MODULE_DECLARE_DATA rewrite_module;' in it, which declares a module called 'rewrite_module'.

The module can be referred to either as 'rewrite_module', which is the identifier, or 'mod_rewrite.c', which is the source file it was compiled from.

The 'LoadModule' line tells it to load the module with the identifier 'rewrite_module' from the already-compiled object mod_rewrite.so. When you configure this, you can either refer to the identifier or the source file name if you know it.

1
  • that explains perfectly thanks. I've never seen a reference to a files pre-compiled file name before so it wasn't clear to me. Commented Feb 25, 2015 at 8:13
1

As @DanielLawson already pointed out, this is clearly described in the Apache manual page you're linking to.

The module argument can be either the module identifier or the file name of the module, at the time it was compiled.

The file name of the module ends with a .c extension, as C is the language Apache httpd is developed in.

A concept of module identifiers is, in turn, similar to Stack Exchange's tags. Your <IfModule mpm_prefork_module> block reads: if you have any module tagged as mpm_prefork_module. This allows for better flexibility in config - different modules offering the same functionality, like mod_ssl.c and mod_gnutls.c both have ssl_module identifier.

4
  • thanks, but as per the previous comments, what I am trying to find out is What is the difference between apache modules with and without the “.c” extension?. e.g. the mod_rewrite.c doesn't seem to exist in my system as a file or a identifier, so therefore would it be wrong for me to reference mod_rewrite.c in a directive? Commented Feb 25, 2015 at 6:46
  • It relates to the module source file - it has .c extension. Commented Feb 25, 2015 at 8:56
  • I see now, thanks (upvoted). I have never seen a pre-compilation file being referred to before so I wasn't "getting it". In that case I assume that referring to mod_rewrite.c would work fine on my system as well as other operating systems then too Commented Feb 25, 2015 at 9:21
  • The practice of referring source file name (and optionally also position) is not uncommon, especially in error messages, exceptions, etc. Commented Feb 25, 2015 at 14:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .