Build Apache Module

1. OS architecture

# uname -a

Linux test 2.6.18-194.el5xen #1 SMP Tue Mar 16 22:01:26 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

2. Apache architecture

# ./apachectl -V

Server version: Apache/2.2.19 (Unix)
Server built:   Aug  7 2012 16:47:58
Server's Module Magic Number: 20051115:28
Server loaded:  APR 1.4.5, APR-Util 1.3.12
Compiled using: APR 1.4.5, APR-Util 1.3.12
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
...

同样方式,可以查看MySQL版本

# mysql -V

mysql  Ver 14.14 Distrib 5.5.28, for Linux (x86_64) using readline 5.1

3. Compile module

# /opt/apache/bin/apxs -c mod_rewrite.c
# /opt/apache/bin/apxs -i -a -n mod_rewrite mod_rewrite.la
# ./apachectl start

httpd: Syntax error on line 23 of /opt/apache/conf/httpd.conf: Cannot load /opt/apache/modules/mod_rewrite.so into server: /opt/apache/modules/mod_rewrite.so: wrong ELF class: ELFCLASS64

# file mod_rewrite.so

mod_rewrite.so: ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), not stripped

4. Compile module in 32-bit (merge command)

# /opt/apache/bin/apxs -Wc,-m32 -i -a -c -n mod_rewrite mod_rewrite.c

/opt/apache/build/libtool --silent --mode=compile gcc -prefer-pic   -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -g -O2 -pthread -I/opt/apache/include  -

I/opt/apache/include   -I/opt/apache/include  -m32  -c -o mod_rewrite.lo mod_rewrite.c && touch mod_rewrite.slo
In file included from /usr/include/features.h:352,
                 from /usr/include/sys/types.h:27,
                 from /opt/apache/include/apr.h:164,
                 from mod_rewrite.c:49:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
apxs:Error: Command failed with rc=65536

5. install gnu/stubs-32.h

# yum install glibc-devel.i686

Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
No package glibc-devel.i686 available.
Nothing to do


6. “This system is not registered with RHN”简单解决办法:
更改yum的源(假定你已安装yum,且网络畅通),即更换/etc/yum.repos.d /rhel-debuginfo.repo 这个文件。
进入/etc/yum.repos.d/目录,终端中输入wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo即可在此目录下得到CentOS- Base.repo文件,这是centos的源文件,只需将其重命名为rhel-
debuginfo.repo即可,以前的文件做个备份。

7. yum

# yum clean all
# yum makecache

8. 一个命令:确认当前程序是否正确调用动态链接库

# ldd mode_rewrite.so


你可能感兴趣的:(Build Apache Module)