Cherokee and Phalcon INVO tutorial

I just got the INVO tutorial to work with the Cherokee webserver on Linux Mint (Ubuntu), and figured I'd share my observations and tweaks.

- My user is part of the www-data group on my system, so to mess with directories and files under www
  I just pay attention to permissions.
- My system has php5-fpm installed instead of php5-fastcgi
- Installation of Cherokee proceeded per the Chero docs, no issues. Hit me up if you want info on how I did it.
- I chose to install the INVO codebase from GitHub in my /var/www directory, in a sub called test.

In a terminal,

sudo mkdir -p /var/www/test
sudo chown -R www-data:www-data /var/www/test
sudo chmod -R 775 /var/www/test
cd test
git clone https://github.com/phalcon/invo.git
cd /var/www/test/invo

In a browser using the cherokee-admin panel, set up a virtual server. Follow the phalcon docs (http://docs.phalconphp.com/en/latest/reference/cherokee.html), but with a few changes. Without the changes, you'll serve only index.php for any page and no controllers will be properly invoked; further, you'll have trouble serving CSS, javascript, and other included files. at least, that's what happened to me. :)

Server Name: test

test->Basics->Document Root: /var/www/test/invo

test->Behavior Rules (under Rule Management, top to bottom, the order is important):
 --Extensions php (per the phalcon docs, no issues or changes), NON FINAL
 --File exists (per the phalcon docs, no issues or changes), FINAL
 --Default <-- THIS IS WHERE THE CHANGES ARE

test->Behavior Rules->Default->Handler (type is Redirection, per the docs)->Rule list
  (top to bottom, the order is important)
  Type           Regular Expression                                         Substitution                      
-----------------------------------------------------------------------------------------------
Internal         \/(.+)\/(css|img|js|flv|swf|download)\/(.+)$"         public$0
Internal         ^(.*)$                                                public/index.php

Finally, in /var/www/test/invo.public/index.php make the following change, under the "Register a user component" section:

$application = new \Phalcon\Mvc\Application();
$application->setDI($di);
echo $application->handle()->getContent();

becomes

$application = new \Phalcon\Mvc\Application();
$application->setDI($di);
if (!empty($_SERVER['REQUEST_URI'])) {
    $pathInfo = $_SERVER['REQUEST_URI'];
} else {
    $pathInfo = '/';
}
echo $application->handle($pathInfo)->getContent();

I found that last bit on Stack Overflow; I don't know why we need it, but I'll find out RSN.

Of course, if I've done something idiotic (entirely probable) feel free to chime in and correct me!

Now that I've got it working, I'm looking forward to delving deeper into this cool framework and more participation in the community.

Cheers!



85.0k

Thanks for contributing