你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu下开启Apache的Rewrite模块

[日期:2017-01-24] 来源:Linux社区  作者:夜太美 [字体:大 中 小]

开启Apache扩展模块

Ubuntu下搭建好LAMP环境之后,如果你需要使用Apache的url重写功能,需要配置文件中启用Apache的Rewrite模块:

1.如果是sudo apt-get install lamp-server^方式搭建的开发环境:

在终端中执行

sudo a2enmod rewrite

指令后,即启用了 Mod_rewrite 模块。
另外,也可以通过将 /etc/apache2/mods-available/rewrite.load 连接到 /etc/apache2/mods-enabled/rewrite.load 来打开 Mod_rewrite 模块。用指令操作就是:

sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

2.如果是源码编译安装的lamp环境:
修改配置文件:/usr/local/apache/conf/httpd.conf
打开LoadModule rewrite_module modules/mod_rewrite.so
即可。

之后重启apache服务即可。

注意:
配置虚拟域名v-hosts.conf时,一定要添加 AllowwOverride All,才可以让apache读取网站目录的.htaccess 文件,自然其中所定义的 rewrite 规则才可以生效。

下面关于LAMP相关的内容你可能也喜欢:

LAMP平台安装Xcache和Memcached加速网站运行  http://www.linuxidc.com/Linux/2015-06/118835.htm

CentOS 7下搭建LAMP平台环境  http://www.linuxidc.com/Linux/2015-06/118818.htm

CentOS 6.5系统安装配置LAMP(Apache+PHP5+MySQL)服务器环境 http://www.linuxidc.com/Linux/2014-12/111030.htm

CentOS 7.2 yum安装LAMP环境  http://www.linuxidc.com/Linux/2016-11/136766.htm

Ubuntu 14.04 配置 LAMP+phpMyAdmin PHP(5.5.9)开发环境  http://www.linuxidc.com/Linux/2014-10/107924.htm

Ubuntu 14.10 下安装 LAMP 服务图文详解  http://www.linuxidc.com/Linux/2014-12/110082.htm

LAMP结合NFS构建小型博客站点  http://www.linuxidc.com/Linux/2015-08/121029.htm

CentOS7下安装部署LAMP环境  http://www.linuxidc.com/Linux/2016-04/130653.htm

Ubuntu Server 14.04 LTS下搭建LAMP环境图文详解  http://www.linuxidc.com/Linux/2016-12/138758.htm

Ubuntu Server 16.04下配置LAMP环境 http://www.linuxidc.com/Linux/2016-12/138757.htm

Ubuntu 16.04搭建LAMP开发环境 http://www.linuxidc.com/Linux/2016-10/136327.htm

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-01/139899.htm

linux
相关资讯       Apache开启Rewrite模块  Apache Rewrite 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款