How to create a phalcon application inside an ispconfig webspace

How to create a Phalcon application inside an ISPConfig webspace.

In this tutorial, I will explain how to create a website using phalconphp. Phalcon is a web framework implemented as a C extension offering high performance, low resource consumption. Phalcon ships as a module that is compiled and loaded inside the webserver. In this example, I will be loading it on a nginx webserver, it is setup to be managed by ISPConfig. It uses php5-fpm ( if you need a tutorial on how to set that up, head over to ).


1.) Compile Phalcon extension and load it in PHP.

installing dependencies for compilation:

sudo apt-get install php5-dev libpcre3-dev gcc make


git clone git://

cd cphalcon/build

sudo ./install

load the module within php5-fpm:

echo "" > /etc/php5/fpm/conf.d/20-phalcon.ini

Finally, restart nginx and php5-fpm.

service nginx restart && service nginx restart


2.) Test it.

Create a file called phpinfo.php in your webroot with the contents:

<?php phpinfo(); ?>

Now, access the site via http://yourserver/phpinfo.php and look for Phalcon. If the module was loaded properly, you should see something similar to:

test if phalcon module got loaded properly

test if phalcon module got loaded properly

3.) Nginx re-write rules.

For Phalcon to turn the URLs into nicely readable URLs /controller/action/param1/param2 etc, you will have to make sure the webserver has the proper rewrite rules loaded. since we installed the website inside an ispconfig webspace, you can just head to the “options” tab in the “website settings” and create a nginx directive there:

nginx rules phalcon

nginx rules phalcon

4.) A bit about ISPConfig’s folder structure:

When you create a website in ISPConfig, it will create a folder in /var/www/clients/clientX/webY ( X being the client ID, Y being the website ID). After the folder has been created, it will create a symlink that links /var/www/ to /var/www/clients/clientX/webY. Inside the webY folder it creates two folders, web and private, so we’ll end up with the following structure for the first website setup in ISPConfig:

/var/www/ ( softlink to /var/www/clients/client1/web1 )

So why a web, AND a private folder inside there?

/var/www/clients/client1/web1/web will be the public web-root of, so it can be accessed by everybody. The /private folder on the other hand, is outside the public area. Meaning, if you have files that should not be accessible by everybody like your template files or your controllers, etc, put them inside /private instead of /web.


You can see a project that better explains this structure on


5.) Setup test project.

5.1.) Start by downloading the files from github to your computer using git:

git clone

5.2.) Create a Database and a Database User on your mysql database

5.3.) Enter the information to this database in the database section of the config.ini

5.4.) Import the database schema.

mysql -u <dbusername> -h <databaseserver> -p <databasename>

mysql> source /path/to/db1.sql

5.5.) You should now be able to access the website, perform login / logout action etc.



No Responses

Leave a Reply

Your email address will not be published.

Powered by