您的位置:首页 > 其它

LAMP下安装phalcon

2014-11-26 00:00 393 查看
摘要: 按照Phalcon的英文文档,安装开源php架构环境phalcon

linux版本为CentOS6.5

安装必须的工具
yum install php-devel pcre-devel gcc make

安装git
yum install git

git到新版本的phalcon,并且编译安装
git clone --depth=1 git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install

安装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>

在test下搭建自己的一个测试工程
结构如下

test/
app/
controllers/
models/
views/
public/
css/
img/

js/
index.php

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!

搭建成功
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  LAMP Phalcon 安装 YUM