喜悦国际村 » PHP高级编程 » Zend Framework配置

页: [1]
xgwork2006-7-10 10:01 AM
Zend Framework配置

这几天有些人一直问我如何配置Zend Framework,应大家的要求,我写了这个.由于自身水平有限,写得不好,还请大家凑合着吧!

1.启用Apache的mod_rewrite模块.

2.让.htaccess生效.(这点很多人没注意)

[code]指令的生效
.htaccess文件中的配置指令作用于.htaccess文件所在的目录及其所有子目录, 但是,很重要需要记住的是,其更高级的目录也可能会有.htaccess文件, 而指令是按查找顺序依次生效,所以, 一个特定目录下的.htaccess文件中的指令可能会覆盖其更高级目录中的 .htaccess文件的指令,即, 子目录中的指令会覆盖更高级目录或者主服务器配置文件中的指令。

例如:

目录/www/htdocs/example1中的.htaccess文件有如下内容:

Options +ExecCGI

(注意: 必须设置"AllowOverride Options"以允许在.htaccess文件中使用 "Options"指令。)

在目录/www/htdocs/example1/example2中的.htaccess文件有如下内容:

Options Includes

由于第二个.htaccess文件的存在,/www/htdocs/example1/example2中 的CGI执行是不允许的,而只允许Options Includes,它完全覆盖了之前的设置。[/code]

我的做法把httpd.conf里面的"Options"指令

[code]<Directory "D:/apche/Apache2/htdocs">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#
    Options FollowSymLinks
    AllowOverride All

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride All

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from All

</Directory>[/code]


看.htaccess是否可以用

[code].htaccess内容

RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css|swf)$ index.php
php_value include_path "./library" [/code]


[color=Red]注意:[/color] 这里的.htaccess在windows无法直接建立.我个人是先建立[color=Red]33.htaccess[/color][color=Red]然后把leaftp打开.找到本地的33.htaccess,重命名位.htaccess[/color]就可以了。哈。.

5.测试下.htaccess是否可以用 打开本地的http://localhost/  随便打入http://localhost/33  看会不会转到http://localhost/ 如果不会说明你的.htaccess没有生效.

4.下载Zend Framework   http://framework.zend.com/download

(解压后把library文件夹放在网站的根目录下)


[color=Red]注意问题:.htaccess一定要让它生效...[/color]

补充问题:  .htaccess里面的php_value include_path 在linux下有的无法使用的。可以通过set_include_path()函数来设置(放在require_once()之前)。
如:index.php里面要这样:
set_include_path('./library');
include 'Zend';
或者你也可以直接在php.ini里面设置.


本文出处:www.phpwb.com


查看完整版本: Zend Framework配置


Powered by Discuz! Archiver 6.1.0  © 2001-2006 Comsenz Inc.
Processed in 0.006005 second(s), 2 queries