2010年4月20日星期二

apache 中如何添加mod_info.c這個文件

最近做實驗,發現在1.3.x , 2.2.x version中mod_status是defult安裝的,但是mod_info不是default安裝的。

如何安裝呢?

------------------apache 1.3.x----
[root@web232 standard]# /usr/local/apache/bin/apxs -cia mod_info.c
apxs:Error: Sorry, no DSO support for Apache available
apxs:Error: under your platform. Make sure the Apache
apxs:Error: module mod_so is compiled into your server
apxs:Error: binary `/usr/local/apache/bin/httpd'.

應該是沒有按照要求進行編譯

./configure --prefix=/usr/local/ --enable-module=so

如果這樣編譯就可以了

在2.2.x環境下
---apache2.2.x----
[root@web233 generators]# /usr/local/apache2/bin/apxs -cia mod_info.c
/usr/local/apache2/build/libtool --silent --mode=compile gcc -prefer-pic   -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -g -O2 -pthread -I/usr/local/apache2/include  -I/usr/local/apache2/include   -I/usr/local/apache2/include   -c -o mod_info.lo mod_info.c && touch mod_info.slo
/usr/local/apache2/build/libtool --silent --mode=link gcc -o mod_info.la  -rpath /usr/local/apache2/modules -module -avoid-version    mod_info.lo
/usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/local/apache2/build/libtool' mod_info.la /usr/local/apache2/modules
/usr/local/apache2/build/libtool --mode=install cp mod_info.la /usr/local/apache2/modules/
cp .libs/mod_info.so /usr/local/apache2/modules/mod_info.so
cp .libs/mod_info.lai /usr/local/apache2/modules/mod_info.la
cp .libs/mod_info.a /usr/local/apache2/modules/mod_info.a
chmod 644 /usr/local/apache2/modules/mod_info.a
ranlib /usr/local/apache2/modules/mod_info.a
PATH="$PATH:/sbin" ldconfig -n /usr/local/apache2/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/apache2/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
chmod 755 /usr/local/apache2/modules/mod_info.so
[activating module `info' in /usr/local/apache2/conf/httpd.conf]
[root@web233 modules]# pwd
/usr/local/apache2/modules
[root@web233 modules]# ls
httpd.exp  mod_info.so

已经增加了
# Example:
# LoadModule foo_module modules/mod_foo.so
LoadModule info_module        modules/mod_info.so  #這個是自動添加上的

添加如下內容:
<Location /server-info>
    SetHandler server-info
    Order deny,allow
    Allow from all    #我這裡是測試環境所以也就這樣設了 production 環境注意一下
</Location>
http://172.16.1.233/server-info

看到信息了

注意httpd.conf中間ExtendedStatus 在2.2.x版本是沒有的

ExtendedStatus On

加上restart apache

就可以看到信息了

没有评论:

发表评论