Skip to content

linux下让apache支持mod_rewrite模块

如果你的服务器apache还没有安装,那很简单,在编译apache时将 mod_rewrite模块编译进去就可以,相关文档可以在http://man.chinaunix.net/newsoft … ew/mod/mod_rewrite. html中找到。如果你的apache已经安装好了,现在只想编译出mod_rewrite.so模块,在apache中进行加载,下面我们就介绍这个方 法。

以Fedora操作系统进行举例:

1)首次安装apache,在编译时增加–enable-rewrite选项。

如./configure –prefix=/opt/apache –enable-so –enable-mods-shared=all –enable-rewrite –enable-cache

2)增加mod_rewrite模块

# find . -name mod_rewrite.c //在apache的源码安装目录中寻找mod_rewrite.c文件

(2.2.8在目录httpd-2.2.8/modules/mappers下,我找了半天才找到的)

# cd PATH/to/mod_rewrite.c //进入包含mod_rewrite.c文件的目录

# /opt/apache/bin/apxs -c mod_rewrite.c //apxs应指定绝对路径,在你当前正在使用apache的bin目录里

# /opt/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

检查:

[root@www httpd-2.2.8]# ../bin/apachectl configtest
Syntax OK

这时,你的apache应该已经支持rewrite了。

vicos注:完成之后,记得重启服务器apache。

注意下一步,配置虚拟主机的时候要类似如下设置才可以生效:

<VirtualHost *:80>
DocumentRoot /var/www/www/www.fastu.cn/
ServerName www.fastu.cn
<Directory /var/www/www/www.fastu.cn/>
Options FollowSymLinks
AllowOverride All
order allow,deny
Allow from all
</Directory>
</VirtualHost>

如果AllowOverride设置为none的话,apache会不读取网站的.htaccess文件!

apache rewrite(9)linux(1)mod_rewrite(7)linux 让apache支持php(1)安装 apache rewrite mod(1)apache rewrite Linux(2)apache mod_rewrite 配置 linux(1)Linux apache2.2 mod_rewrite.so(1)linux mod_rewrite 配置(2)mod_rewrite.so 下载(36)linux rewrite(15)linux apache支持php(4)apache rewrite 安装(1)mod_rewrite.so下载(22)linux apache 2.2.8(1)

Share in Google Reader Share in Google Reader 分享到 FriendFeed 分享到 FriendFeed 推荐到豆瓣 推荐到豆瓣 分享到 Twitter 分享到 Twitter

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*

无觅相关文章插件,快速提升流量