PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训 » 操作系统(Windows、Linux) » Apache安装rewrite模块
本页主题: Apache安装rewrite模块 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

狼剑



该用户目前不在线
级别: 新手上路
精华: 1
发帖: 43
威望: 45 点
金钱: 450 PYMB
贡献值: 0 点
在线时间:2(小时)
注册时间:2006-11-24
最后登录:2008-12-11

Apache安装rewrite模块


安装环境:rhel es 4
apache:1.3.37(源码自己编译安装)
gdbm:1.8.3

1. Apache安装rewrite模块的时候需要DBM支持,否则无法编译,表现为:


[nemo@web standard]$ ~/apache/bin/apxs -c mod_rewrite.cgcc -DLINUX=22 -DHAVE_SET_DUMPABLE -DUSE_HSREGEX -fpic -DSHARED_MODULE -I/home/nemo/apache/include  -c mod_rewrite.cIn file included from mod_rewrite.c:51:mod_rewrite.h:91:18: ndbm.h: No such file or directorymod_rewrite.c: In function `lookup_map_dbmfile':mod_rewrite.c:3035: error: `DBM' undeclared (first use in this function)mod_rewrite.c:3035: error: (Each undeclared identifier is reported only oncemod_rewrite.c:3035: error: for each function it appears in.)mod_rewrite.c:3035: error: `dbmfp' undeclared (first use in this function)mod_rewrite.c:3036: error: `datum' undeclared (first use in this function)mod_rewrite.c:3036: error: syntax error before "dbmkey"mod_rewrite.c:3044: error: `dbmkey' undeclared (first use in this function)mod_rewrite.c:3047: error: `dbmval' undeclared (first use in this function)apxs:Break: Command failed with rc=1[nemo@web standard]$ rpm -qa |grep gdbn[nemo@web standard]$ rpm -qa |grep gdbmgdbm-1.8.0-24gdbm-devel-1.8.0-24

所以首先要安装一个GDBM :下载地址:ftp://ftp.gnu.org/gnu/gdbm/
GDBM安装步骤: 进入安装目录,


./configuremakemake installmake install-compat #否则无法编译出ndbm.h头文件.

2. 然后进入到apache源码包解压目录apache_1.3.37/src/modules/standard,用Apache bin目录下的apxs命令安装,注意apxs使用绝对路径:


cd /path/to/apache_1.3.37/src/modules/standard//usr/local/apache/bin/apxs -c mod_rewrite.c /usr/local/apache/bin/apxs -i -a -n mod_rewrite mod_rewrite.so

然后在http.conf配置文件里加上:


LoadModule rewrite_module libexec/mod_rewrite.so

接下来用


/usr/local/apache/bin/apachectl stop/usr/local/apache/bin/apachectl start

停止apache,然后用再start,千万注意,在这里不能用restart或者graceful参数来重新启动apache,必须先停止,然后再开始,否则rewrite将不起作用。

如果你跟我一样的不幸,遇到dbm_fetch错误问题,那么请按我的尝试来操作:

执行完/usr/local/apache/bin/apxs -i -a -n mod_rewrite mod_rewrite.so后,这个命令已经帮我们复制mod_rewrite.so模块到libexec目录下并且修改好了httpd.conf文件,但测试却出现dbm_fetch错误:


[root@web conf]# ../bin/apachectl configtest
Syntax error on line 16 of /home/nemo/apache/conf/httpd.conf:Cannot load /home/nemo/apache/libexec/mod_rewrite.so into server: /home/nemo/apache/libexec/mod_rewrite.so: undefined symbol: dbm_fetch

google一下,马上发现一篇文章写有解决方法(本文最后贴出),继续尝试:
到 apache_1.3.37/src/modules/standard 目录,执行一下这个命令:


gcc -shared -o mod_rewrite.so mod_rewrite.o -lgdbmcp mod_rewrite.so /usr/local/apache/libexec/

重新检查一下:


[root@web conf]# ../bin/apachectl configtest
Syntax error on line 16 of /home/nemo/apache/conf/httpd.conf:Can't locate API module structure `mod_rewrite_module' in file /home/nemo/apache/libexec/mod_rewrite.so: /home/nemo/apache/libexec/mod_rewrite.so: undefined symbol: mod_rewrite_module

修改 httpd.conf ,将


LoadModule mod_rewrite_module libexec/mod_rewrite.so改为LoadModule mod_rewrite libexec/mod_rewrite.so

检查一下:


[root@web conf]# ../bin/apachectl configtest
Syntax error on line 16 of /home/nemo/apache/conf/httpd.conf:Can't locate API module structure `mod_rewrite' in file /home/nemo/apache/libexec/mod_rewrite.so: /home/nemo/apache/libexec/mod_rewrite.so: undefined symbol: mod_rewrite

靠!再改:


LoadModule rewrite_module libexec/mod_rewrite.so

检查:


[root@web conf]# ../bin/apachectl configtest

Syntax OK

NND,总算搞定了!


[root@web conf]# ../bin/apachectl restart  ../bin/apachectl restart: httpd restarted

-------------------------------------
google到的解决方法:


http://www.vttoth.com/rewrite.htmTechnical Notes: Undefined symbol 'dbm_fetch' with the Apache serverI tried to include in my Apache Web server's configuration the mod_rewrite module, but when I restarted the server, I received an error:Cannot load /usr/local/apache/libexec/mod_rewrite.so into server:/usr/local/apache/libexec/mod_rewrite.so: undefined symbol: dbm_fetchThe problem, as it turns out, is that mod_rewrite.so is compiled incorrectly. It should be linked with a dbm library but it isn't.If you have an up-to-date set of Apache source files, you can easily solve this problem by manually rerunning the last compilation step of this module, using the correct options. When you execute make mod_rewrite.so in the appropriate directory, it performs this final step:gcc -shared -o mod_rewrite.so mod_rewrite.loRerun gcc, this time adding a reference to the GNU gdbm library:gcc -shared -o mod_rewrite.so mod_rewrite.lo -lgdbmNext, copy the newly created mod_rewrite.so over to /usr/local/apache/libexec or wherever your Apache module files are located.In my case, this was all that was needed to solve the problem. Your mileage
顶端 Posted: 2007-11-02 22:15 | [楼 主]
PHP学会网 php培训网 PHP暑期培训 PHP寒假培训 PHP假期培训 » 操作系统(Windows、Linux)

时:01-10 07:04 Copyright © 2006 phpwhy.com 权
ICP05060669

曳息 -