一、大概思路
1.1、

(備注:安裝Zend Framework,其附帶apache2和php5)
1.2、

二、Zend Framework配置
2.1、安裝Zend Framework
在ubuntu10.10的軟件中心安裝zf.

2.2、激活apache的rewrite模塊
命令行輸入:sudo a2enmod rewrite
2.3、配置PHP5路徑
配置include_path路徑信息,修改/etc/php5/con.d目錄下的zend-framework.ini
終端輸入:sudo gedit /etc/php5/conf.d/zend-framework.ini

2.4、創(chuàng)建firstProject項(xiàng)目
終端輸入:zf create project firstProject
(其路徑默認(rèn)為 Ubuntu主文件目錄下)

2.5、在Apache2建立firstProject項(xiàng)目配置文件
因?yàn)?/span>apache默認(rèn)的web目錄是在/var/www下,為了能夠讓 apache自動(dòng)定位到指定目錄下的web應(yīng)用,這里我們?cè)?/span>/etc/apache2/conf.d中創(chuàng)建一個(gè)關(guān)于firstProject的配置文件,稱(chēng)為 firstProject.conf。
終端輸入:sudo gedit /etc/apache2/conf.d/firstProject.conf
文件的內(nèi)容是:
IfModule alias_module>
Alias /firstProject "/home/administrator/firstProject/public/"
Directory "/home/administrator/firstProject/public/">
Allow from all
RewriteEngine on
RewriteBase /firstProject
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !\.(css|js|jpg|gif|png|swf|flv)$ index.php
Options FollowSymlinks MultiViews
AllowOverride All
/Directory>
/IfModule>
2.6、修改項(xiàng)目firstProject的public文件下的.htaccess
增加一行RewriteBase /firstProject
(.htaccess默認(rèn)是隱藏的,可按快捷鍵Ctrl+H顯示出來(lái))
RewriteEngine On
RewriteBase /firstProject
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
2.7、啟動(dòng)運(yùn)行http://localhost/firstProject

三、Zend Framework顯示hello
3.1、從終端進(jìn)入firstProject文件夾內(nèi),運(yùn)行zf create Controller showhello
3.2、編寫(xiě)application/controllers/ShowhelloController.php
?php
class ShowhelloController extends Zend_Controller_Action {
public function init() {
/* Initialize action controller here */
}
public function indexAction() {
// action body
$this->view->content = "Hello World";
$this->render ();
}
}
3.3、編寫(xiě)application/views/scripts/showhello/index.phtml
center>View script for controller b>Showhello /b> and script/action
name b>index/b>
p>font color="#FF0000">
?=$this->content;?>
/font>/p>
/center>
3.4、運(yùn)行http://localhost/firstProject/showhello
四、總結(jié)
配置環(huán)境雖然是件很麻煩的事,但是只要花一些時(shí)間,總可以找到相應(yīng)的解決方法。