Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is it possible to install phalcon (a custom PHP PECL extension/module) on a shared web hosting service that uses cPanel, or is it normally something that requires root access?

That is, can I still somehow get the benefits of phalcon on my existing host without having to rent a VPS?

share|improve this question

closed as off-topic by EEAA, mdpc, Ladadadada, dyasny, cole Jun 26 '14 at 18:17

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – EEAA, mdpc, dyasny, cole
If this question can be reworded to fit the rules in the help center, please edit the question.

While I certainly appreciate your QA here, it's off-topic for Serverfault. Perhaps it would be more appropriate at Stackoverflow or webmasters.SE. –  EEAA Jun 22 '14 at 18:38
Hi @EEAA, apologies if it was miscategorized. Are cPanel questions not suitable for ServerFault? Since it's not specifically a programming question, I thought the draconian mods at StackOverflow would be even less likely to accept it. Can it be migrated to Webmasters.SE? Or do I need to copy & paste it? –  Simon Jun 22 '14 at 23:10
Five people closed the thread without responding to my question. Thank you. * frown * –  Simon Jul 3 '14 at 5:55
thanks for posting and answering this, it being closed is a fine example of the elitism here that is complained about by various users. –  Hayden Thring Dec 7 '14 at 6:28

1 Answer 1

Your web host may install custom extensions for you, it can't hurt to ask.

But most, generally, will recommend you upgrade to a VPS which allows you full root access, the ability to install anything you want, and less risk that you will negatively impact performance for other users of the server. VPSs can require extra administration effort and technical knowledge unless you opt for a "Managed VPS" which usually adds a significant monthly cost.

And so, assuming my host would not want to enable a custom extension for me, I set out to discover if I could do it on my own. I found a way of doing so without even needing SSH or command-line access.

Step 1: Obtain phalcon.so

You need to obtain the correct build of phalcon.so for your server environment and version of PHP.

cPanel generally runs on CentOS, Red Hat Enterprise Linux (RHEL), or CloudLinux. The phalcon site offers some binary versions for download, but sadly nothing for CentOS/RHEL.

Here are the files I compiled for CentOS 64bit with PHP 5.3 and 5.4. You're welcome to try that if you like until others make binaries available, or see below for instructions on how to compile your own.

https://dl.dropboxusercontent.com/u/9911892/phalcon/1.3.2/PHP5.3/phalcon.so https://dl.dropboxusercontent.com/u/9911892/phalcon/1.3.2/PHP5.4/phalcon.so

Upload this via FTP to your home directory.

Step 2: Enable the extension

You need to add the following line to php.ini:

extension = /home/__USERNAME__/phalcon.so

(Replace __USERNAME__ with your actual cPanel username)

I'm not sure whether all cPanel hosts are like this, but my host VentraIP allows you to put a custom php.ini or .user.ini file in your public_html folder which overrides the default PHP settings.

You can get a hint at whether this is possible by uploading <?php phpinfo(); to a file on your server and call it from your browser. Hopefully you'll have a line like the one below...

custom PHP.ini file

Otherwise you might have to use .user.ini files which are shown like this...

.user.ini file PHP

Note that with .user.ini files, these are commonly cached by the server for 300 seconds, so if you make a change to one, it may take up to 5 minutes for the change to take effect.

Step 3: Verify that it works

Refresh your phpinfo() page in the browser. If phalcon has loaded correctly, you will find an additional section displayed that looks like this:

phalcon phpinfo extension enabled

If you've got this far, hooray!

Not working?

Enable error logging by adding error_log = /home/__USERNAME__/error.log to your php.ini or .user.ini and refresh the phpinfo() file. Then check the log or any obvious errors. If you're not getting any error and phalcon is not showing up, then it's likely that your server is not reading your ini file correctly. Is it definitely in your public_html folder? Have you tried both php.ini and .user.ini formats?

On my first try I started getting this error appearing in my logs:
PHP Warning: PHP Startup: Unable to load dynamic library '/home/yumpstag/phalcon.so' - /home/yumpstag/phalcon.so: undefined symbol: output_globals in Unknown on line 0

I found out that I had the wrong version of phalcon.so (built for PHP 5.3 instead of 5.4) and so had to recompile it.

How to compile phalcon.so (or another extension) yourself

Chances are, you won't be able to run a compiler on your cPanel server without root access, so you'll need to find a similar server to do this on. Here's what I did:

The next step is to ensure you have the correct major version of PHP installed, this needs to match what you're using on your cPanel web host. If you want a different version of PHP other than the default that CentOS supports (PHP 5.3 at the time of writing), try this:

sudo rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
sudo yum install php54w-devel        # FOR PHP 5.4 ONLY

(Otherwise, to go with the CentOS default version:)

sudo yum install php-devel           # FOR PHP 5.3 ONLY

Then install the remaining prerequisites:

sudo yum install php-mysql gcc libtool git

Fetch phalcon and compile:

git clone --depth=1 git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install

Once it has finished, it will tell you where the phalcon.so file is. You can then upload that via FTP to your cPanel home directory.

sudo yum install ftp
ftp myhostname.com
put /usr/lib64/php/modules/phalcon.so /phalcon.so

Then go back to steps 2 and 3 to complete the process.

Hope that helps some others. Please comment below if you have any additional tips to offer.

share|improve this answer
Why did you answer your own question? Is this a posting like "hey world look what I know"? –  deagh Jun 22 '14 at 14:39
Hi @deagh, yes, doing so is encouraged. See here: serverfault.com/help/self-answer –  Simon Jun 22 '14 at 14:50
thx for the link and... good job ;) –  deagh Jun 22 '14 at 14:51
I also found another blog post which documents a very similar thing on their host HostGator. That may also help some: wpmarketing.org/2013/09/… –  Simon Jun 22 '14 at 14:57
just a note for future attempts, if you want to identify the correct centos version your host runs, look at top of phpinfo() output titled "System": 2.6.32-531.23.3.lve1.2.66.el6.x86_64 from the start of this you can get the kernel version and architecture and then match it against the list at wikipedia: en.wikipedia.org/wiki/CentOS#CentOS_releases (click show) –  Hayden Thring Dec 9 '14 at 1:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.