httpd.conf的设置(Symfony)

本文介绍如何为Symfony项目配置Apache服务器的httpd.conf文件,包括启用mod_rewrite模块及设置虚拟主机来支持Symfony应用的路径重写。

httpd.conf的设置(Symfony)

Symfony显示‘简短漂亮的(smart)’路径时用到了 mod_rewrite 模块。如果你的Apache版本没有将 mod_rewrite 模块编译进去,那么需要在 httpd.conf 中检查模块mod_rewrite是否是动态模块方式(DSO)安装的,并且确认是否已经打开(译者注:关于Apache的mod_rewrite模块安装和使用方法请参考Apache相关文档,这里假设读者已经具备这方面知识而不作过多说明):

AddModule mod_rewrite.c
LoadModule rewrite_module modules/mod_rewrite.so

httpd.conf 配置文件中加入一个新的虚拟主机

>Directory "C:/php5/pear/data/symfony/web/sf"<
AllowOverride All
Allow from All
>/Directory<
>VirtualHost *:80<
ServerName myfp
DocumentRoot "D:/httpServer"
DirectoryIndex index.php
Alias /sf "C:/php5/pear/data/symfony/web/sf"

>Directory "D:/httpServer"<
AllowOverride All
Allow from All
>/Directory<
>/VirtualHost<

>Directory "/$data_dir/symfony/web/sf"<
 AllowOverride All
 Allow from All
>/Directory<
>VirtualHost *:80<
  ServerName myapp.example.com
  DocumentRoot "/home/steve/myproject/web"
  DirectoryIndex index.php
  Alias /sf /$data_dir/symfony/web/sf

  >Directory "/home/steve/myproject/web"<
   AllowOverride All
   Allow from All
  >/Directory<
>/VirtualHost<

注意:上面的配置中的 $data_dir 变量需要替换成你的PEAR库目录。例如:在*nix系统中,你可以输入:

    Alias /sf /usr/local/lib/php/data/symfony/web/sf

【作者: Liberal】【访问统计:】【2007年08月11日 星期六 17:59】【注册】【打印】

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值