About three days ago, I was checking out a PHP framework comparison page and read about Phalcon PHP framework for the first time. It caught my eyes because it was the fastest PHP framework ever! It’s because it’s implemented as C-Extension in PHP modules.

So I was thinking that I should try this in my Hostgator shared account. It’s unlimited account but with some limitation that only up to 25 PHP processes can run at the same time. This means the 26th visitor will see an error message. See my previous blog article on the limitations. Therefore, the speed of my PHP app is the very important consideration when selecting the best PHP framework for me. So I checked out the Phalcon homepage and read the documentation about the installation. Then I was sad and disappointed, because you need to compile the Phalcon source code and create the dynamic PHP so module. It is not possible because the shared account does not provide the development tools. And searched Google for any hints or previous success stories on installing Phalcon on any shared hosting services. But I was only able to find a comment that says it may not be possible.

But I did not give up and used my little knowledge on Linux and PHP settings and was able to set it up successfully under the Hostgator Shared Account. It cost me one beautiful sunny Saturday.

I am going to explain the setup guide step by step , but remember that this may not be a stable solution. Here is the steps of what I did.

Installed Linux in my desktop using VirtualBox. It’s free for personal use and you can run other OS in your Windows PC.

Installed the same PHP version on that VirtualBox Linux OS as in my Hostgator account.

Compiled the Phalcon PHP module under the VirtualBox Linux.

Use customized php.ini file.

It seems working fine. I downloaded the INVO demo and it is working just fine. Also you can confirm the successful installation by running phpinfo() function.

One thing to note is that , if Hostgator upgrades the PHP version of your shared account machine, your PHP app won’t work until you recompile and update the Phalcon module.

Now are you ready?

[Requirements]

Your hosting server’s PHP version must be 5.3.9 and up.

SSH access to your shared account

Some knowledge on Linux and PHP config file (php.ini)

VirtualBox (free download) , Linux Distro ISO (I used CentOS 5.9. I will explain later why I selected this version)

[Step 1] Install CentOS-5.9 in your VirtualBox

You must first find out if your shared hosting server is 32bit or 64bit. When you run uname command, if you see x86_64, then it is 64 bit . If you see i386 or i686, then it is 32 bit.

You have to download the same version of CentOS-5.9. My account was 64bit, so I downloaded x86_64 version of CentOS DVD.

Then , in the VirtualBox, create a new machine and install CentOS.

Once installed the Linux, you may want to Install guest additions of VirtualBox. While this is an optional step, it will make your life much easier. Also you need developer tools installed in your VirtualBox Linux OS. Log in as root and open the terminal application. Then run below commands.

Then click on the Devices –> Install Guest Additions menu of the VirtualBox. Then click on the autorun.sh to install the guest additions program.

[Step 2] Install PHP 5.3.27 in the VirtualBox Linux OS.

You will need to check the PHP version of the hosting server. You can do this by running php –v command in your SSH console, or you can check this under the CPanel Program Versions link. Note that if you see 5.2 version, then you can enable 5.3 version using .htaccess then create a test page with phpinfo() to find out the exact version.

You can download the PHP source code from php.net and compile your self, but it is a quite challenging task. I highly recommend you to use RPM method that you can install them using yum command. But you have to find out if such RPM package exists.

Note that I chose CentOS 5.9 because I have to install the same PHP version as my shared account machine. My shared account server has PHP 5.3.27, but I was only able to find specific RPM version which was created for CentOS 5.9 . So in order to install this PHP RPM, I had to use CentOS 5.9.

Before doing this, you must install the development tools. Run below command in your VirtualBox Linux.

yum groupinstall "Development Tools"

Download the source from the GitHub and unzip, then run install under build subfolder

cd cphalcon/build
./install

If the compilation is successful, the compiled phalcon module will resides in below location.

cphalcon/build/32bits/modules/phalcon.so

If it’s 64 bits , check this path

cphalcon/build/64bits/modules/phalcon.so

Now upload this phalcon.so file into your Hostgator shared account.

[Step 4] PHP configuration – php.ini setting

In the .htaccess file of your web app’s root folder, add below

<IfModule mod_suphp.c>
suPHP_ConfigPath /home/youruserid/php53
<Files php.ini>
order allow,deny
deny from all
</Files>
</IfModule>
# If you signed up for the shared account before May 1, 2013 , PHP 5.2 is the default version.
# Then, you need to activate below line to enable PHP 5.3
# AddType application/x-httpd-php53 .php

I will use /home/youruserid/php53 path to store the customized php.ini file and phalcon.so file.

Then checkout the phpinfo() output to check the below item.

Loaded Configuration File

First copy the Loaded Configuration File into /home/youruserid/php53.

cp /opt/php53/lib/php.ini /home/youruserid/php53

Then edit the /home/youruserid/php53/php.ini file. Add below extension option at the end of the php.ini file.

extension=/home/youruserid/php53/ext/phalcon.so

Now create the /home/youruserid/php53/ext folder then upload the phalcon.so file into the /home/youruserid/php53/ext folder.

Now , please try to run the phpinfo() function and check the output. Do you see the “phalcon” string in the output page? If you don’t, check out the error_log. It shows the error message and will help you to troubleshoot easily.

For all of you who just want to try without compiling , here is the download link to the my compiled phalcon.sofile for 64bit OS.

I just got some questions regarding how to use my Hana Flv Player Plugin (For the ones that are not familar, this is one of the top WordPress Video player plugins 🙂 ). It was started as a simple plugin and it was pretty simple to use first, but has come a long way and now it could be kind of confusing after the installation. So I created this quick simple guide.

Requirements

You need to install and activate Hana Flv Player.

You need to have FLV or mp4 video file in your desktop or if it’s already in your site, you need to know the exact full URL of your flv or mp4 video file.

1. Make sure Hana Flv Player is activated under Plugins admin menu.

2. Now create a new post . Goto Posts-> Add New. Click on the quick tag tool bar button named “Hana Flv”. A new dialog window will pop up.

3. This window will help you create short tag to be used within the body of the post. In this window, you can define the video URL, Description , Which video player to use, width and height of the video player , and many other options. After defining options, you can click the “OK” button . Then the corresponding short tag will appear in the body of content text field.

4. Right now, “Video URL” field is the only mandatory attribute data. In the “Video URL” field, you can insert full video URL manually or you can upload a video from your PC or select video file by using the default media library interface. Click on the “Upload or Browse Video”. You can upload or browse the video file to use. Then click the “Insert into Post” button. This will insert the URL of the video file into the “Video URL field” of the Hana Flv Video dialog.

5. Now it’s basically ready . If you want, you can select or define other options. Once you are done, click on the “OK” button.

6. Now the appropriate shortcode is created in the post. You may click on the “Preview” button to see the preview.

You don’t need to use the Dialog but directly copy and paste the example shorttag from the Hana Flv Player settings page, then edit as you needed.

[hana-flv-player
video="http://wpt.aws.af.cm/wp-content/plugins/hana-flv-player/babyhana.flv"
width="400"
height="320"
description="Sarah is having fun in a merry-go-round"
clickurl="http://wpt.aws.af.cm"
clicktarget="_blank"
player="4"
autoplay="false"
loop="false"
autorewind="true"
splashimage="http://wpt.aws.af.cm/wp-content/plugins/hana-flv-player/splash.jpg"
skin=""
/]
Another sample of auto height
[hana-flv-player
video="http://wpt.aws.af.cm/wp-content/plugins/hana-flv-player/sarah.flv"
width="350"
height=""
description="Sarah is having fun at the beach"
player="4"
/]
This is a sample of HTML5 player with mp4 video file playing
[hana-flv-player
video="http://wpt.aws.af.cm/wp-content/plugins/hana-flv-player/hana_sleding.mp4"
description="Hana is having fun while sleding"
player="5"
autoplay="false"
autoload="true"
loop="true"
/]

Attributes explained:

video: URL of the flv video file. This is mandatory.

width: Width of the Flash player.

height: Height of the Flash player. If not defined, automatically calculated using 4:3 ratio. If 16:9 ratio is needed, use ‘autow’ as height.

description: Description of the video. This will be shown when the_excerpt() is used. Also it is used within the SWF objects or javascripts, so search engines can read it.

clickurl: If you want to open a website when a user clicks on the video, you can define the target website URL here.

clicktarget: The target of the URL when clicking on the video. Same window:_self, New window _blank

Hosting Service Tip

Thinking of getting Wordpress Hosting? Then choose Hostgator. Make sure you select the shared hosting account - Baby package . It's the most affordable and fully featured package. You can even host multiple domains with the same account.

Hostgator provides the best environment for PHP application (64 MB of PHP memory) and stable system. I am using other hosting services, but Hostgator is the best. Link Directly to Shared Web Hosting Page