LAMP下安装phalcon

linux版本为CentOS6.5

  1. 安装必须的工具

    yum install php-devel pcre-devel gcc make

  2. 安装git

    yum install git

  3. git到新版本的phalcon,并且编译安装

    git clone --depth=1 git://github.com/phalcon/cphalcon.git

    cd cphalcon/build

    sudo ./install

  4. 安装Notes

    在httpd.conf中修改你的主目录为/var/www/test

    添加

    <IfModule mod_rewrite.c>

    <Directory "/var/www/test">

    RewriteEngine on

    RewriteRule ^$ public/ [L]

    RewriteRule (.*) public/$1 [L]

    </Directory>

    <Directory "/var/www/test/public">

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]

    </Directory>

    </IfModule>

  5. 在test下搭建自己的一个测试工程

    结构如下

  6. test/

         app/

         controllers/

         models/

         views/

    public/

         css/

         img/

         js/

          index.php

  7. index.php内容

<?php
try {
//Register an autoloader
$loader = new \Phalcon\Loader();
$loader->registerDirs(array(
’../app/controllers/’,
’../app/models/’
))->register();
//Create a DI
$di = new Phalcon\DI\FactoryDefault();
//Setup the view component
$di->set(’view’, function(){
$view = new \Phalcon\Mvc\View();
$view->setViewsDir(’../app/views/’);
return $view;
});
//Setup a base URI so that all generated URIs include the "tutorial" folder
$di->set(’url’, function(){
$url = new \Phalcon\Mvc\Url();
$url->setBaseUri(’/tutorial/’);
return $url;
});
//Handle the request
$application = new \Phalcon\Mvc\Application($di);
echo $application->handle()->getContent();
} catch(\Phalcon\Exception $e) {
echo "PhalconException: ", $e->getMessage();
}

    8.添加一个controller

<?php
class IndexController extends \Phalcon\Mvc\Controller
{
public function indexAction()
{
echo "<h1>Hello!</h1>";
}
}

页面会显示一个hello!

搭建成功

转载于:https://my.oschina.net/sunjin/blog/349011

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值