Installing FuelPHP on Plesk 12

installing fuelphp on plesk 12

Plesk 12 comes with a range of pre-built installation wizards for a number of the most popular PHP CMS’ on the market, such as WordPress, Drupal and Joomla, but not for the major PHP frameworks, such as Zend Framework 2, FuelPHP, Laravel and Symfony.

This is a little unfortunate, but it’s no deal breaker; and to be fair, as they’re frameworks, not complete applications, it makes sense. Given the flexibility of Plesk 12, as administrators, developers and dev ops, we’re able to do take care of all the necessary steps manually.

In today’s tutorial, we’ll step through the process of setting up and deploying a basic FuelPHP 4 application on Plesk 12. By the time we’re done, you’ll see the site as in the screenshot below.

fuelphp on plesk 12

Before we get started, I should say that it won’t be a shining example, world-beating, application but it will have the core FuelPHP 4 framework installed, ready to use.

What Is FuelPHP

Started in October 2010 by Harro Verton, Jelmer Schreuder, Dan Horrigan, Philip Sturgeon and Frank de Jonge, FuelPHP,

is a simple, flexible, community driven PHP 5 web framework. It was born out of the frustrations people have with the current available frameworks and developed with support from a community of developers. FuelPHP is extremely portable, works on almost any server and prides itself on clean syntax.

I chose this one because it combines power with simplicity. So it’s a good package to use, whether you’re a beginner or more experienced developer.

Similar to Laravel, Ruby on Rails and Zend Framework 2, FuelPHP comes complete with a URL routing system, RESTful and HMVC implementation, support for multiple template engines, including MustacheMarkdownSmartyTwig and Haml, an ORM, Auth package and caching system.

To know more about it, check out the FuelPHP website or the Wikipedia documentation.

Prerequisites

To complete today’s tutorial, you’re only going to need a few prerequisites. These are:

  • Git
  • Awk
  • Root access (or user with sufficient privileges or who’s in the sudoers list)

Getting Setup

Right, so what do we need to do to set it up? Thanks to the modern UI, and intelligent layout available in Plesk 12, it’s a real no brainer, requiring only a few steps to have it live, which are as follows:

  1. Create a Sub-Domain
  2. Setup SSH Access
  3. Install FuelPHP
  4. Install Composer
  5. Configure FuelPHP
  6. View The Application

Let’s work through the process now.

Create a Sub-Domain

When you first login to your account, click the Domains in the left-hand side navigation bar, under Hosting Services. This will then show you the list of your websites & domains.

In our example, we have a few existing ones; but to keep this simple, we’re going to create a new sub-domain, specifically under huffyscrew.com. On the far right of that domain’s row in the table, click “Manage Hosting“. This will display the domain and sub-domain entries, which you can see in the screenshot below.

domain manage hosting plesk12 screenshot phpfuel

Above the first entry, you’ll see three buttons: “Add New Domain“, “Add New Subdomain” and “Add New Domain Alias“. Click “Add New Subdomain”, and on the form which appears, enter “fuelphp” for the subdomain name. The Document root field will be pre-populated, based on the Subdomain name you entered. 

The reason for this is that the command we’ll run to install FuelPHP creates a sub-directory, called fuel, and the application’s bootstrap file is located in the public directory beneath that. It may take a minute or two for the subdomain to be created, based on your server’s specifications. But it shouldn’t take too long.

When it’s finished you’ll be back on the domains page you started at, with your new domain available at the bottom of the list. In the entry, you’ll see all the pertinent details, along with links to more, as well as to make changes.

Setup SSH Access

Now we need to check that SSH access is setup properly, so that we can login and run a few command line scripts. If you’re not too familiar with command line scripts, that’s ok. The one’s I’ve listed here are quite simple and have sufficient documentation, should it be needed.

web hosting access plesk12 screenshot fuelphp

At the bottom of the subdomain’s entry, click the tab titled “Show More“, then click the first entry in the exposed list, titled “Web Hosting Access“. On the page that appears, you’ll see four sections.

configure ssh access plesk12 screenshot fuelphp

In the second section, titled “System user“, make sure that the last option, “Access to the server over SSH“, is set to /bin/bash or /bin/sh and click OK at the bottom.

The reason for this is because these scripts need that environment to run in. sh may work, but bash works best for this example. Now you’re ready to login and begin installing the application.

 

Installing FuelPHP

Now let’s get cracking and create our first FuelPHP application. Like many things in life, there’s a few ways to do it. You can use the scaffolding tool, called Oil or you can manually install it by cloning the Github repository and carrying out all the configuration by hand. As the latter is a bit error-prone and Oil is the preferred way to do it, we’ll be using Oil.

Oil is a utility which facilitates quick development, testing applications and running tasks, such as building MVC components, migrations, scaffolding, installing updating and removing packages and running PHPUnit tests.

Install Oil

So first, run the command below, which will install the oil binary in /usr/bin/oil. So make sure your user has sufficient permissions or is in the shudders list before continuing.

curl get.fuelphp.com/oil | sh && which oil

This command should print out /usr/bin/oil as the last part of the output, verifying that oil’s installed.

Create a FuelPHP Project

With oil installed, we can now use it to create a new project, which we’ll call fuel. To do so, first cd to the virtual host directory, then run the command below:

oil create fuel

As it’s executing, you should see output such as that below, which has been truncated for readability:

Initialized empty Git repository in
 /var/www/vhosts/conetixtest.com/fuelphp.conetixtest.com/fuel/.git/
remote: Counting objects: 15218, done.
remote: Total 15218 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (15218/15218), 5.11 MiB | 890 KiB/s, done.
Resolving deltas: 100% (6115/6115), done.
Already on '1.7/master'
Updating to version 4ecdbf89c4a3d1e5dfe73c57e3202a5e2a18c87e.
    Downloading: 100%         
Use composer self-update --rollback to return to version
 e77435cd0c984e2031d915a6b42648e7b284dd5c
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing composer/installers (dev-master 41cf781)
    Cloning 41cf781ed1271e25bf31b715416a349996aa2527

  - Installing fuel/docs (1.7.2)
    Downloading: 100%         

  - Installing fuel/core (1.7.2)
    Downloading: 100%         

  - Installing fuel/auth (1.7.2)
    Downloading: 100% 

Writing lock file
Generating autoload files

Satisfy All External Dependencies

composer homepage screenshot

FuelPHP uses PHP’s dependency manager, Composer, to manage all it’s dependencies. If you’re not familiar with Composer, in years gone by, many projects implemented common functionality, such as routing, database layers, caching interaction and logging on their own.

This made it difficult to port applications to newer or different frameworks, or for them to be maintained in a cost and time-effective. Composer makes it almost painless for best of breed libraries for any specific purpose to be created, voted on, discovered and most importantly used in applications.

If you don’t have Composer installed, run the following command to do so:

curl -s https://getcomposer.org/installer | php --

This will download Composer, piping it through to PHP, creating a self-contained phar file we can use from the command line. With that done run the following command, inside the new fuel project directory, to download all the dependencies:

php composer.phar self-update && php composer.phar update;

Verify Directory Permissions

Now that that’s done, there’s one last step to go, which is to verify directory permissions. This is required as FuelPHP makes use of several directories for caching, configuration and logging amongst other things.

We can verify the directory permissions are correctly set by again using oil, as in the command below:

php oil refine install
    Made writable: APPPATH/cache
    Made writable: APPPATH/logs
    Made writable: APPPATH/tmp
    Made writable: APPPATH/config

Potential Errors

With that done, the project’s created and ready to go. However, during the course of running the above commands, you may have come across the error below:

Error - date_default_timezone_get(): It is not safe to rely on the system's
timezone settings. You are *required* to use the date.timezone setting or the
date_default_timezone_set() function. 

In case you used any of those methods and you are still getting this warning,
you most likely misspelled the timezone identifier. We selected the timezone
'UTC' for now, but please set date.timezone to select your timezone. in
COREPATH/classes/fuel.php on line 167

If you do, it’s a simple one to fix and sometimes common in PHP installations. To fix it, edit thedate.timezone setting in your PHP’s main configuration file. If you’re not sure where it’s located, run the following command:

vim $(php -i | grep 'Loaded Configuration File' | awk -F ' => ' '{print $2}')

This will print out the full path to the file. Once you’re in the file, locate the section headed[Date], then ensure that the setting for date.timezone is both uncommented and has a valid value.

If you’re not sure of the required setting for your area, consult PHP’s list of supported timezones.

View The Application

Right, now that it’s installed, let’s have a look at the running app. It’s not special, as there’s no database, logging, or caching server connections. It’s just a one page application, but it works and looks like the screenshot below:

fuelphp on plesk 12

Wrapping Up

So there you go. In just a few minutes, we’ve stepped through creating and configuring a sub-domain, to installing a basic FuelPHP application.

Now it’d be great if it was simpler, such as having an installer for Drupal, Joomla and WordPress. But it’s a bit hard to compare off the shelf applications, such as these, to frameworks which allow for creating nearly any kind of application.

What I’m hoping for is to have an installer which lays the foundation for this process, which may just be available in the future.

Till then, share your thoughts in the comments. Has this made it simpler for you to start creating FuelPHP applications on Plesk? I hope so. I’d love to hear how you feel.

Back to the Blog

avatar of matthew setter

Matthew Setter

  • Conetix
  • Conetix

Let's Get Started

  • This field is for validation purposes and should be left unchanged.