• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Ubuntu10.10 Zend FrameWork配置方法及helloworld显示

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

、大概思路

1.1

(备注:安装Zend Framework,其附带apache2php5)

1.2、

 

Zend Framework配置

2.1、安装Zend Framework

ubuntu10.10的软件中心安装zf.

2.2、激活apacherewrite模块

命令行输入: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、创建firstProject项目

终端输入:zf create project firstProject

(其路径默认为 Ubuntu主文件目录下)

 

2.5、在Apache2建立firstProject项目配置文件

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

终端输入:sudo gedit /etc/apache2/conf.d/firstProject.conf

文件的内容是:

复制代码
代码如下:

<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、修改项目firstProjectpublic文件下的.htaccess

增加一行RewriteBase /firstProject

.htaccess默认是隐藏的,可按快捷键Ctrl+H显示出来)

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、启动运行http://localhost/firstProject

 

Zend Framework显示hello 

3.1、从终端进入firstProject文件夹内,运行zf create Controller showhello 
3.2、编写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、编写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、运行http://localhost/firstProject/showhello

四、总结

配置环境虽然是件很麻烦的事,但是只要花一些时间,总可以找到相应的解决方法。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
ubuntu下网页打开慢的解决方法发布时间:2022-02-11
下一篇:
Ubuntu 10.10 配置 Zend Framework发布时间:2022-02-11
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap