参见:http://www.51testing.com/html/76/n-218876.html
1. 在apache的源码安装目录中寻找mod_rewrite.c文件
# find . -name mod_rewrite.c
2. 进入包含mod_rewrite.c文件的目录
# cd PATH/to/mod_rewrite.c
# /usr/local/apache/bin/apxs -c mod_rewrite.c //apxs应指定绝对路径,在你当前正在使用apache的bin目录里
# /usr/local/apache/bin/apxs -i -a -n mod_rewrite mod_rewrite.la
如果没有什么错误的话,应该在你的apache的modules目录中编译出一个mod_rewrite.so文件。
编辑httpd.conf文件,确认httpd.conf中已经包含mod_rewrite.so的加载语句,如下:
LoadModule rewrite_module modules/mod_rewrite.so
3. 加载
用命令:
/usr/local/apache/bin/apxs -i -a -c /usr/local/software/httpd-2.2.15/modules/mappers/mod_rewrite.c
或命令:
# /usr/local/apache/bin/apxs -c /usr/local/software/httpd-2.2.15/modules/mappers/mod_rewrite.c
# /usr/local/apache/bin/apxs -i -a -n rewrite //usr/local/software/httpd-2.2.15/modules/mapperss/mappers/mod_rewrite.la
如果没有什么错误的话,应该在你的apache的modules目录中编译出一个mod_rewrite.so文件。
4.出错处理
在执行第三步的命令报错:
/usr/local/apache/build/instdso.sh: –mode=install: 没找到
apxs:Error: Command failed with rc=65536
解决办法:
#gcc -shared -o mod_rewrite.so /usr/local/software/httpd-2.2.15/modules/mappers/mod_rewrite.o
在/usr/local/software/httpd-2.2.15/modules/mappers下生成mod_rewrite.so
# cp mod_rewrite.so /usr/local/apache/modules/
5.编辑httpd.conf文件,添加:
LoadModule rewrite_module modules/mod_rewrite.so
6.重启apache