complains if this is not the case. You can check this yourself by manually
running the command</p>
- <div class="example"><p><code>
- $ httpd -l
- </code></p></div>
+ <div class="example"><pre class="prettyprint lang-sh">$ httpd -l</pre>
+</div>
<p>The module <code class="module"><a href="../mod/mod_so.html">mod_so</a></code> should be part of the displayed list.
If these requirements are fulfilled you can easily extend your Apache
server's functionality by installing your own modules with the DSO mechanism
by the help of this <code>apxs</code> tool:</p>
- <div class="example"><p><code>
- $ apxs -i -a -c mod_foo.c<br />
- gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c<br />
- ld -Bshareable -o mod_foo.so mod_foo.o<br />
- cp mod_foo.so /path/to/apache/modules/mod_foo.so<br />
- chmod 755 /path/to/apache/modules/mod_foo.so<br />
- [activating module `foo' in /path/to/apache/etc/httpd.conf]<br />
- $ apachectl restart<br />
- /path/to/apache/sbin/apachectl restart: httpd not running, trying to start<br />
- [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module<br />
- /path/to/apache/sbin/apachectl restart: httpd started<br />
- $ _
- </code></p></div>
+ <div class="example"><pre class="prettyprint lang-sh">$ apxs -i -a -c mod_foo.c
+gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c
+ld -Bshareable -o mod_foo.so mod_foo.o
+cp mod_foo.so /path/to/apache/modules/mod_foo.so
+chmod 755 /path/to/apache/modules/mod_foo.so
+[activating module `foo' in /path/to/apache/etc/httpd.conf]
+$ apachectl restart
+/path/to/apache/sbin/apachectl restart: httpd not running, trying to start
+[Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module
+/path/to/apache/sbin/apachectl restart: httpd started
+$ _</pre>
+</div>
<p>The arguments <var>files</var> can be any C source file (.c), a object
file (.o) or even a library archive (.a). The <code>apxs</code> tool
<p>Use this to manually determine settings used to build the
<code>httpd</code> that will load your module. For instance use</p>
- <div class="example"><p><code>
- INC=-I`apxs -q INCLUDEDIR`
- </code></p></div>
+ <div class="example"><pre class="prettyprint lang-sh">INC=-I`apxs -q INCLUDEDIR`</pre>
+</div>
<p>inside your own Makefiles if you need manual access to Apache's C
header files.</p></dd>
first have to compile the C source into a shared object suitable for loading
into the Apache server under runtime via the following command:</p>
- <div class="example"><p><code>
- $ apxs -c mod_foo.c<br />
- /path/to/libtool --mode=compile gcc ... -c mod_foo.c<br />
- /path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo<br />
- $ _
- </code></p></div>
+ <div class="example"><pre class="prettyprint lang-sh">$ apxs -c mod_foo.c
+/path/to/libtool --mode=compile gcc ... -c mod_foo.c
+/path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo
+$ _</pre>
+</div>
<p>Then you have to update the Apache configuration by making sure a
<code class="directive"><a href="../mod/mod_so.html#loadmodule">LoadModule</a></code> directive is present to
and updating the <code>httpd.conf</code> file accordingly. This can be
achieved by running:</p>
- <div class="example"><p><code>
- $ apxs -i -a mod_foo.la<br />
- /path/to/instdso.sh mod_foo.la /path/to/apache/modules<br />
- /path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
- ...
- chmod 755 /path/to/apache/modules/mod_foo.so<br />
- [activating module `foo' in /path/to/apache/conf/httpd.conf]<br />
- $ _
- </code></p></div>
+ <div class="example"><pre class="prettyprint lang-sh">$ apxs -i -a mod_foo.la
+/path/to/instdso.sh mod_foo.la /path/to/apache/modules
+/path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
+...
+chmod 755 /path/to/apache/modules/mod_foo.so
+[activating module `foo' in /path/to/apache/conf/httpd.conf]
+$ _</pre>
+</div>
<p>This way a line named</p>
- <div class="example"><p><code>
- LoadModule foo_module modules/mod_foo.so
- </code></p></div>
+ <div class="example"><pre class="prettyprint lang-config">LoadModule foo_module modules/mod_foo.so</pre>
+</div>
<p>is added to the configuration file if still not present. If you want to
have this disabled per default use the <code>-A</code> option,
<em>i.e.</em></p>
- <div class="example"><p><code>
- $ apxs -i -A mod_foo.c
- </code></p></div>
+ <div class="example"><pre class="prettyprint lang-sh">$ apxs -i -A mod_foo.c</pre>
+</div>
<p>For a quick test of the apxs mechanism you can create a sample Apache
module template plus a corresponding Makefile via:</p>
- <div class="example"><p><code>
- $ apxs -g -n foo<br />
- Creating [DIR] foo<br />
- Creating [FILE] foo/Makefile<br />
- Creating [FILE] foo/modules.mk<br />
- Creating [FILE] foo/mod_foo.c<br />
- Creating [FILE] foo/.deps<br />
- $ _
- </code></p></div>
+ <div class="example"><pre class="prettyprint lang-sh">$ apxs -g -n foo
+Creating [DIR] foo
+Creating [FILE] foo/Makefile
+Creating [FILE] foo/modules.mk
+Creating [FILE] foo/mod_foo.c
+Creating [FILE] foo/.deps
+$ _</pre>
+</div>
<p>Then you can immediately compile this sample module into a shared object
and load it into the Apache server:</p>
- <div class="example"><p><code>
- $ cd foo<br />
- $ make all reload<br />
- apxs -c mod_foo.c<br />
- /path/to/libtool --mode=compile gcc ... -c mod_foo.c<br />
- /path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo<br />
- apxs -i -a -n "foo" mod_foo.la<br />
- /path/to/instdso.sh mod_foo.la /path/to/apache/modules<br />
- /path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
- ...
- chmod 755 /path/to/apache/modules/mod_foo.so<br />
- [activating module `foo' in /path/to/apache/conf/httpd.conf]<br />
- apachectl restart<br />
- /path/to/apache/sbin/apachectl restart: httpd not running, trying to start<br />
- [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module<br />
- /path/to/apache/sbin/apachectl restart: httpd started<br />
- $ _
- </code></p></div>
+ <div class="example"><pre class="prettyprint lang-sh">$ cd foo
+$ make all reload
+apxs -c mod_foo.c
+/path/to/libtool --mode=compile gcc ... -c mod_foo.c
+/path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo
+apxs -i -a -n "foo" mod_foo.la
+/path/to/instdso.sh mod_foo.la /path/to/apache/modules
+/path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
+...
+chmod 755 /path/to/apache/modules/mod_foo.so
+[activating module `foo' in /path/to/apache/conf/httpd.conf]
+apachectl restart
+/path/to/apache/sbin/apachectl restart: httpd not running, trying to start
+[Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module
+/path/to/apache/sbin/apachectl restart: httpd started
+$ _</pre>
+</div>
</div></div>
<div class="bottomlang">
running the command</p>
<example>
- $ httpd -l
+<highlight language="sh">
+$ httpd -l
+</highlight>
</example>
<p>The module <module>mod_so</module> should be part of the displayed list.
by the help of this <code>apxs</code> tool:</p>
<example>
- $ apxs -i -a -c mod_foo.c<br />
- gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c<br />
- ld -Bshareable -o mod_foo.so mod_foo.o<br />
- cp mod_foo.so /path/to/apache/modules/mod_foo.so<br />
- chmod 755 /path/to/apache/modules/mod_foo.so<br />
- [activating module `foo' in /path/to/apache/etc/httpd.conf]<br />
- $ apachectl restart<br />
- /path/to/apache/sbin/apachectl restart: httpd not running, trying to start<br />
- [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module<br />
- /path/to/apache/sbin/apachectl restart: httpd started<br />
- $ _
+<highlight language="sh">
+$ apxs -i -a -c mod_foo.c
+gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c
+ld -Bshareable -o mod_foo.so mod_foo.o
+cp mod_foo.so /path/to/apache/modules/mod_foo.so
+chmod 755 /path/to/apache/modules/mod_foo.so
+[activating module `foo' in /path/to/apache/etc/httpd.conf]
+$ apachectl restart
+/path/to/apache/sbin/apachectl restart: httpd not running, trying to start
+[Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module
+/path/to/apache/sbin/apachectl restart: httpd started
+$ _
+</highlight>
</example>
<p>The arguments <var>files</var> can be any C source file (.c), a object
<p>Use this to manually determine settings used to build the
<code>httpd</code> that will load your module. For instance use</p>
<example>
- INC=-I`apxs -q INCLUDEDIR`
+<highlight language="sh">
+INC=-I`apxs -q INCLUDEDIR`
+</highlight>
</example>
<p>inside your own Makefiles if you need manual access to Apache's C
into the Apache server under runtime via the following command:</p>
<example>
- $ apxs -c mod_foo.c<br />
- /path/to/libtool --mode=compile gcc ... -c mod_foo.c<br />
- /path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo<br />
- $ _
+<highlight language="sh">
+$ apxs -c mod_foo.c
+/path/to/libtool --mode=compile gcc ... -c mod_foo.c
+/path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo
+$ _
+</highlight>
</example>
<p>Then you have to update the Apache configuration by making sure a
achieved by running:</p>
<example>
- $ apxs -i -a mod_foo.la<br />
- /path/to/instdso.sh mod_foo.la /path/to/apache/modules<br />
- /path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
- ...
- chmod 755 /path/to/apache/modules/mod_foo.so<br />
- [activating module `foo' in /path/to/apache/conf/httpd.conf]<br />
- $ _
+<highlight language="sh">
+$ apxs -i -a mod_foo.la
+/path/to/instdso.sh mod_foo.la /path/to/apache/modules
+/path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
+...
+chmod 755 /path/to/apache/modules/mod_foo.so
+[activating module `foo' in /path/to/apache/conf/httpd.conf]
+$ _
+</highlight>
</example>
<p>This way a line named</p>
<example>
- LoadModule foo_module modules/mod_foo.so
+<highlight language="config">
+LoadModule foo_module modules/mod_foo.so
+</highlight>
</example>
<p>is added to the configuration file if still not present. If you want to
<em>i.e.</em></p>
<example>
- $ apxs -i -A mod_foo.c
+<highlight language="sh">
+$ apxs -i -A mod_foo.c
+</highlight>
</example>
<p>For a quick test of the apxs mechanism you can create a sample Apache
module template plus a corresponding Makefile via:</p>
<example>
- $ apxs -g -n foo<br />
- Creating [DIR] foo<br />
- Creating [FILE] foo/Makefile<br />
- Creating [FILE] foo/modules.mk<br />
- Creating [FILE] foo/mod_foo.c<br />
- Creating [FILE] foo/.deps<br />
- $ _
+<highlight language="sh">
+$ apxs -g -n foo
+Creating [DIR] foo
+Creating [FILE] foo/Makefile
+Creating [FILE] foo/modules.mk
+Creating [FILE] foo/mod_foo.c
+Creating [FILE] foo/.deps
+$ _
+</highlight>
</example>
<p>Then you can immediately compile this sample module into a shared object
and load it into the Apache server:</p>
<example>
- $ cd foo<br />
- $ make all reload<br />
- apxs -c mod_foo.c<br />
- /path/to/libtool --mode=compile gcc ... -c mod_foo.c<br />
- /path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo<br />
- apxs -i -a -n "foo" mod_foo.la<br />
- /path/to/instdso.sh mod_foo.la /path/to/apache/modules<br />
- /path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
- ...
- chmod 755 /path/to/apache/modules/mod_foo.so<br />
- [activating module `foo' in /path/to/apache/conf/httpd.conf]<br />
- apachectl restart<br />
- /path/to/apache/sbin/apachectl restart: httpd not running, trying to start<br />
- [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module<br />
- /path/to/apache/sbin/apachectl restart: httpd started<br />
- $ _
+<highlight language="sh">
+$ cd foo
+$ make all reload
+apxs -c mod_foo.c
+/path/to/libtool --mode=compile gcc ... -c mod_foo.c
+/path/to/libtool --mode=link gcc ... -o mod_foo.la mod_foo.slo
+apxs -i -a -n "foo" mod_foo.la
+/path/to/instdso.sh mod_foo.la /path/to/apache/modules
+/path/to/libtool --mode=install cp mod_foo.la /path/to/apache/modules
+...
+chmod 755 /path/to/apache/modules/mod_foo.so
+[activating module `foo' in /path/to/apache/conf/httpd.conf]
+apachectl restart
+/path/to/apache/sbin/apachectl restart: httpd not running, trying to start
+[Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module
+/path/to/apache/sbin/apachectl restart: httpd started
+$ _
+</highlight>
</example>
</section>