How to Install and Set Up FuelPHP on VPS


FuelPHP is an open source web application framework based on HMVC (Hierarchical Model-View-Controller) pattern. It makes use of ‘Oil’, a tool for generating code, debugging and performing database migrations.

This tutorial will guide you to install FuelPHP on your VPS and get started with small applications.


  • Web server (Apache, Nginx and IIS)
  • PHP 5.3+
  • Ubuntu powered VPS
  • LAMP stack installation


Installation of FuelPHP


For installing FuelPHP, we use curl command.

curl | sh

The oil package will be downloaded into the /usr/bin folder on your cloud server. Now, we need to quickly install Git as oil needs the application code.

sudo apt-get update
sudo apt-get install git-core

Now, you need to create the FuelPHP application. For that, go to the web server document root /var/www for Apache, and run the command:

oil create fuel

This fetches all the necessary files using Git and dependent libraries using Composer and will place them into a folder names ‘fuel’. You can navigate to IP-address/fuel/public in your browser to take a look at the front page of your application.

In case if you wish to access web server’s document root straight from your IP address or domain name, you can change the same to point directly to public folder of your FuelPHP application. To achieve it, edit the virtual host file as shown:

nano /etc/apache2/sites-available/default

Search for the ‘document root’ and replace the root path.


DocumentRoot /var/www/


DocumentRoot /var/www/fuel/public/

Restart Apache to bring in all the changes.

sudo service apache2 restart

For removing the index.php extension from the FuelPHP url, verify if .htaccess files can override default Apache instructions. To accomplish that, mod_rewrite has to be enabled. You can check the available modules by running the following command.

apache2ctl -M

If ‘rewrite_module’ is in the list displayed, then you can proceed, If it’s not present, run the command to enable mod_rewrite.

a2enmod rewrite

Now, you have to edit the apache default virtual host file to set ‘Allow Override’ to ‘All’.

nano /etc/apache2/sites-available/default

Make appropriate changes to the following snippet.

<Directory /var/www/
>Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all


Once the virtual host file is updated, you need to set the default timezone in php.ini file.

nano /etc/php5/apache2/php.ini

Uncomment the line and set the timezone accordingly.


;date.timezone =


date.timezone = America/Toronto

Save the file and restart apache.

sudo service apache2 restart

Create a Database

We need to create an empty database for our application. We can create a database by using MySQL or MariaDB. Log in to the terminal and run the command.

create database fuel;

The database will be created. Exit the terminal and return to the application. Now, edit the config file to make the following changes:

nano /var/www/fuel/fuel/app/config/config.php

Uncomment the always_load array, the packages array and the orm package. This ensures that FuelPHP loads the ORM package in order to create working models. Save and exit.

Let’s set the database connection by updating the db.php file in var/www/fuel/fuel/app/config/development/ folder.

nano /var/www/fuel/fuel/app/config/development/db.php

Make necessary changes to database and other required fields. Save and exit the file.


Generate Scaffolding for Article Models

Scaffolding refers to a set of controllers, models and views to define the application database and contains the default CRUD operations code. For example, let’s assume that our application deals with articles that require a title and a body. Here, we can generate the scaffolding by issuing the command from /var/www/fuel as given below:

oil generate scaffold articles title:string body:text

This command will generate the scaffolding that defines a title of type string and body of type text. You can locate the new controller, model and view files inside fuel/app/classes folder. Now, we need to create a table to house the article content. For that run migrate command as:

oil refine migrate

The table will be created as per the instructions in the /var/www/fuel/fuel/app/migrations/001_create_articles.php file generated with scaffolding. FuelPHP automatically generates 3 columns to the table, along with the given structure. So, in our example,  when you check the database, you will see the table ‘articles’ with 5 columns, named id, title, body, create_at, updated_at. The first column and the last two were generated by FuelPHP.

Now, you will be able to add, delete, update and view articles as you wish. Navigate your browser to the articles controller to perform required CRUD operations on article model.

support2 has written 111 articles

Leave a Reply