debian下安装zendframework

时间:2022-11-15 15:40:20

第一步,打开apache的rewrite模块,因为在debian下使用apache必须执行这一步

a2enmod rewrite #激活rewrite模块 
/etc/init.d/apache2 restart #激活后要重启apache服务器

第二步,安装Zend Framework

apt-get install zendframework

成功安装后Zend库的位置位于/usr/share/php/Zend目录下。

第三步,配置include_path路径信息。

修改/etc/php5/apache2下面的php.ini文件。将;include_path = ".:/usr/share/php"前面的“;”号去掉。然后执行/etc/init.d/apache2 restart #激活后要重启apache服务器

测试代码。在/var/www文件夹下面建立一个文件phpinfo.php并将下面的代码复制在里面。

<?php

phpinfo();

?>

复制完毕之后在浏览器中访问该文件。然后就可以查看include_path已经更改了。

debian下安装zendframework

测试:看是否能调用zf的类,在var/www/下面建立一个date.php文件代码如下

<?php

require_once("Zend/Date.php");

$date = new Zend_Date();

echo $date;

?>

debian下安装zendframework

第四步:安装zendframework-bin这个可以用命令创建项目和模块等等的。方便。。。

Apt-get install zendframework-bin

第五步:使用zf命令创建web应用。

用cd命令切换到将要创建项目的那个文件夹。然后执行下面代码:

zf create project zftest

效果如下:

debian下安装zendframework

第六步:配置apache关于本项目的信息。

因为apache默认的web目录是在/var/www下,为了能够让 apache自动定位到指定目录下的web应用,这里我们在/etc/apache2/conf.d中创建一个关于zftest的配置文件,称为 zftest.conf。文件的内容是:

<IfModule alias_module> 
Alias /zftest "/home/youngfer/zftest/public/" 
<Directory "/home/youngfer/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>

第七步:修改public里的.htaccess文件。

RewriteEngine On 
RewriteBase /zftest 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ - [NC,L] 
RewriteRule ^.*$ index.php [NC,L]

第八步:重启apache服务器

/etc/init.d/apache2 restart

第九步:显示结果

debian下安装zendframework

完成了!也许我是幸运的!可能你在搭建的时候会出现问题!请耐心的找出问题,并干掉它!