单独编译apache的rewrite模块

简介:
单独编译apache的rewrite模块

装好了一个基于M od x 网站

在IE里面 访问时,出来的页面是apache内部错误,请联系管理员

查看 apache 错误日志里面内容如下

[Tue Nov 25 23:46:41 2008] [alert] var/www/ xxx/ .htaccess: Invalid command 'RewriteEngine', perhaps mis-spelled or defined by a module not included in the server configuration

根据.htaccess的内容,需要apache支持rewrite模块

我先把.htaccess文件重命名(即不启用rewrite模块),发现是可以访问页面的,所以是我的apache 编译时 没有rewrite模块引起的问题

现在单独编译这个模块

进入apache的源码目录

# cd httpd-2.0.59

# cd modules

# cd mappers/

# ls  

会列出很多文件,其中 mod_rewrite.c   这个就是rewrite模块的源码文件

# /usr/local/apache2/bin/apxs -i -a -c ./mod_rewrite.c

输出如下

/usr/local/apache2/build/libtool --silent --mode=compile gcc -prefer-pic  -DAP_HAVE_DESIGNATED_INITIALIZER -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/apache2/include  -I/usr/local/apache2/include   -I/usr/local/apache2/include   -c -o ./mod_rewrite.lo ./mod_rewrite.c && touch ./mod_rewrite.slo

/usr/local/apache2/build/libtool --silent --mode=link gcc -o ./mod_rewrite.la  -rpath /usr/local/apache2/modules -module -avoid-version    ./mod_rewrite.lo

/usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/local/apache2/build/libtool' ./mod_rewrite.la /usr/local/apache2/modules

/usr/local/apache2/build/libtool --mode=install cp ./mod_rewrite.la /usr/local/apache2/modules/

cp ./.libs/mod_rewrite.so /usr/local/apache2/modules/mod_rewrite.so

cp ./.libs/mod_rewrite.lai /usr/local/apache2/modules/mod_rewrite.la

cp ./.libs/mod_rewrite.a /usr/local/apache2/modules/mod_rewrite.a

ranlib /usr/local/apache2/modules/mod_rewrite.a

chmod 644 /usr/local/apache2/modules/mod_rewrite.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_rewrite.so

[activating module `rewrite' in /usr/local/apache2/conf/httpd.conf]

由输出可以看到rewrite模块已经在httpd.conf中激活了,查看确认

# vi /usr/local/apache2/conf/httpd.conf

可以看到

# LoadModule foo_module modules/mod_foo.so

LoadModule php5_module        modules/libphp5.so

LoadModule rewrite_module     modules/mod_rewrite.so

重启apache生效

把.htaccess文件恢复为这个文件名,访问正常显示页面



本文转自yahoon 51CTO博客,原文链接:http://blog.51cto.com/yahoon/115951,如需转载请自行联系原作者

相关文章
|
8月前
|
Ubuntu PHP
Ubuntu下使用apt为Apache2编译PHP7.1
以上就是在Ubuntu系统下,使用apt为Apache2编译PHP7.1的过程。希望这个过程对你有所帮助,如果你在执行过程中遇到任何问题,都可以在网上找到相关的解决方案。
156 25
|
8月前
|
Ubuntu PHP Apache
在Ubuntu系统中为apt的apache2编译PHP 7.1的方法
以上就是在Ubuntu系统中为apt的apache2编译PHP 7.1的方法。希望这个指南能帮助你成功编译PHP 7.1,并在你的Apache服务器上运行PHP应用。
192 28
|
12月前
|
Java Maven
Maven编译报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile 解决方案
在执行Maven项目中的`install`命令时,遇到编译插件版本不匹配的错误。具体报错为:`maven-compiler-plugin:3.13.0`要求Maven版本至少为3.6.3。解决方案是将Maven版本升级到3.6.3或降低插件版本。本文详细介绍了如何下载、解压并配置Maven 3.6.3,包括环境变量设置和IDEA中的Maven配置,确保项目顺利编译。
12716 5
Maven编译报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile 解决方案
|
应用服务中间件 Apache nginx
apache、nginx开启rewrite重写服务及伪静态
apache、nginx开启rewrite重写服务及伪静态
681 4
|
存储 缓存 Ubuntu
如何在 Apache Web 服务器中安装、配置和使用模块
如何在 Apache Web 服务器中安装、配置和使用模块
229 0
|
运维 Linux Apache
LAMP架构调优(九)——Apache Rewrite功能实战
LAMP架构调优(九)——Apache Rewrite功能实战
161 1
|
存储 缓存 负载均衡
【Apache ShenYu源码】如何实现负载均衡模块设计
整个模块为ShenYu提供了什么功能。我们可以看下上文我们提到的工厂对象。/***/核心方法很清晰,我们传入Upsteam列表,通过这个模块的负载均衡算法,负载均衡地返回其中一个对象。这也就是这个模块提供的功能。
202 1
|
Java Apache Maven
在STS里使用Gradle编译Apache POI5.0.0
在STS里使用Gradle编译Apache POI5.0.0
195 0
|
Java
apache-incubator-streampark源码编译本地运行(七)
apache-incubator-streampark源码编译本地运行(七)
184 1
|
Java Apache 数据库
下一代实时数据库:Apache Doris 【二】编译与安装
下一代实时数据库:Apache Doris 【二】编译与安装
771 0

推荐镜像

更多