简体   繁体   中英

How to load a complete library in Apache2.4

I created a custom module for Apache2.4 that uses an external library (MagickWand). I installed it using sudo apt-get install libmagickwand-dev , but now, what I have to do in order to use it with Apache2.4? When I restart the apache2 service I got the undefined symbol error about a function on MagickWand. I read that I should load the shared object of the library, but how can I create it? Using apxs? Where?

Thank you very much in advance!

there are two config files in apache2 that you will need to modify:

(for linux)

in the /etc/apache2 there are sub directories of interest:

./mods-available and ./mods-enabled and ./conf-available and ./conf-enabled

The ./mods-available directory contains ALL the loadable modules, all with the .load extension on their file name

The ./mods-enabled directory contains links to the loadable modules in the ./mods-available directory that are to be loaded and links to the .conf file for each of the .conf files (for the individual loadable modules) that are actually to be loaded.

the ./conf-available directory contains all the .conf files for the loadable modules

The ./conf-enabled directory contains links to the files in the ./conf-available directory for the loadable modules configurations that will be actually used

Then in the /etc/apache2 directory is the file apache2.conf that can contain (amongst other things) these two statements:

IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

This is what directs apache2 to actually load modules and their related conf files

The following response is to help others:

In order to compile a custom apache module using apxs with MagickWand library, first include the header file wand/magick-wand.h in your C file. Let's say it is mod_example.c:

So, in mod_example.c add:

#include "wand/magick-wand.h"

Now, when compiling the module using apxs include the directories which MagickWand will require during the build process using -I flag and mention the library name using -l flag

sudo apxs -c -i -I/usr/include/ImageMagick-6 -I/usr/include/x86_64-linux-gnu/ImageMagick-6 -lMagickWand-6.Q16 /path/to/mod_example.c

Please note, your library version may be different.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM