首先创建Zend项目有多种方式:
1.下载好文件,执行解压后/bin目录下的脚本文件
2.使用sudo apt-get install zendframework 安装zend,以下是这种方法:
使用命令安装:
sudo apt-get install zend-framework,安装成功后zend目录为/usr/share/PHP/libzend-framework-php
也可以使用composer来创建
composer create-project zendframework/zendframework1 ZF1 --prefer-dist
配置:
配置include_path路径:
修改/etc/php5/conf.d目录下的zend-framework.ini文件,仅需将include_path前的分号去掉后保存即可
开启rewrite:
在命令行下输入命令:sudo a2enmod rewrite,后重启apahce服务器
开启PHP各种模块:
pdo_mysqli等等。
用zf命令创建web project:
zf create project 项目名
运行结果如下:
zf create project testZend
Creating project at /var/www/testZend
Note: This command created a web project, for more information setting up your VHOST, please see docs/README
Testing Note: PHPUnit was not found in your include_path, therefore no testing actions will be created.
发现include_path找不到PHPunit,所以单元测试不能创建。(这个问题目前还不知道怎么解决)
然后是vhost虚拟主机:
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf(开启这一行)
配置apache关于本项目的信息
在/etc/apache2/conf.d中创建一个关于ZFTest的配置文件,称为 zftest.conf。文件的内容是:
<IfModule alias_module>
Alias /zftest "/home/limin/Zend/workspaces/DefaultWorkspace7/ZFTest/public/"
<Directory "/home/limin/Zend/workspaces/DefaultWorkspace7/ZFTest/public/">
Allow from all
RewriteEngine on
RewriteBase /zftest
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !\.(css|js|jpg|gif|png|swf|flv)$ index.php
Options FollowSymlinks MultiViews
AllowOverride All
</Directory>
</IfModule>
修改ZFTest目录中public子目录里的.htaccess文件(为隐藏文件)
在RewriteEngine On后添加一句 RewriteBase /zftest
之后只要访问目录或域名,会自动加载public下的index.php,也就是view里的index.phtml(我也不知道为什么是.phtml)