Phalcon on shared hosting

Since this has an extension to be installed on the server. This cannot be used on shared hosting servers right? Because hosting providers such as godaddy do not allow us to do much. Is there a work around on this?



81.7k

No, Phalcon can't be installed on shared hostings unless you have ssh root access. Try to find a hosting provider on this list: http://phalconphp.com/en/hosting



42

Hello, basically you need to compile the Phalcon somewhere else where C compiler exists (has to be linux with the same architecture -X86 or X64), then you need to copy the compiled phalcon.so into your hosting account. This is only possible if your hosting account supports CPanel with php.ini quick config. Basically you can use any other PHP modules by using this method.

Note that the PHP versions must match . If your shared hosting server is using 5.3 (This is minimum requirement to use Phalcon), you need to compile where PHP 5.3 is installed. It appears that the minor version can be different. For example, module compiled under PHP 5.3.9 does work under hosting account where PHP 5.3.27 is used.

Check my blog posting for the details.

http://wpmarketing.org/2013/09/phalcon-php-framework-on-hostgator-shared-hosting-account/



9.3k

@chris: Thank for information, its enough to compile the phalcon so file and put it in the host and add so file address to php.ini ? PHP version is ok. but not sure about C extension on the host, it just use to compile phalcon.so file ?



42
edited Mar '14

@ksharifi : I am not sure about other hosting providers , but under hostgator it works. If other hosting providers provide CPanel, I believe you can run custom compiled C extension so files. Actually I found that I did not mention this on my blog article, but when you login CPanel , if you see "php.ini quickconfig" menu, I am 99% sure that you will be able to use customized php.ini file. Basically this means mod_suphp is activated.

There are three important files to activate

1: compiled phalcon.so file Let's say your complied so file is in /home/yourid/ext/phalcon.so

2: customized php.ini file with phalcon.so activated Let's say this php.ini file is located in /home/yourid/ext/php.ini

#php.ini file
extension=/home/yourid/ext/phalcon.so

3: your website's document root folder's .htaccess file . This must include mod_suphp entry pointing to the customized php.ini file

#.htaccess file

<IfModule mod_suphp.c>
        suPHP_ConfigPath /home/yourid/ext/php.ini
        <Files php.ini>
                order allow,deny
                deny from all
        </Files>
</IfModule>

Please refer to my blog posting (in my previous post) for more information

Thanks



9.3k
edited Mar '14

@Chris: Thank you very much for dedicat your time to me.



42
edited Mar '14

Basically using the above method, you can run any C compiled so extensions . But There are two issues that you should be aware of.

First, I am not sure 100% , but since I am using a custom php.ini file, it seems like it is being read everytime user visit my website. This could mean that the custom extension files are also being read & loaded every visit too. If this is true, the website can become slower due to the extension loading time if the so files are big. This is purely my assumption. So this may not be true.

Second, any php memory caching extention will not work under any shared hosting account. I believe this is because they run suPHP which blocks or limits memory utilization. Due to this reason, if your phalconphp app uses any APC or memory cache function, it will be really slow.

I tested Phalcon's invo application, and enjoyed the fast processing speed only for few seconds. Soon I realized that there is very long delay while running DB accessing Model routines. They took at least 6~ 15 seconds to see the output (compared to the native PHP accessing time is 1~2 seconds).

After checking several places, I realized it is related to the default modelsMetadata model I used.

In the config.ini , the default metadata section enable was APC for caching. This is to create cache of the DB table metadata to make the app faster.

[metadata]
adapter = "Apc"
suffix = my-suffix
lifetime = 86400

But you see this APC adapter utilizes memory to store the metadata cache. This was the reason. Once I changed to use file system, the speed was much faster!

Here are the routines I changed .

In public/index.php

$di->set('modelsMetadata', function() use ($config) {
        if (isset($config->metadata)) {
                $metaDataConfig = $config->metadata;
                $metadataAdapter = 'Phalcon\Mvc\Model\Metadata\\'.$metaDataConfig->adapter;

                if ($config->metadata->adapter == 'Files' ) {
                        $mda=new $metadataAdapter(array('metaDataDir' =>__DIR__. $config->metadata->metaDataDir));
                }else
                        $mda=new $metadataAdapter();

                return $mda;

        }

        return new Phalcon\Mvc\Model\Metadata\Memory();
});

In app/config/config.ini

[metadata]
adapter="Files"
metaDataDir=/../cache/metadata/

For the first few loadings of pages involving DB access, you may experience some sluggish speed while the file metadata are being created. But after few tries, the speed becomes much more faster than before. Just remember to delete files under metaDataDir after you update the DB tables structures.

But it's really hard to tell phalconphp gives super speed boost under shared hosting accounts. It may be different for your case, though. So try yourself and share the result!

Again , you can visit my blog page for detailed instruction how to run Phalconphp under shared hosting account. http://wpmarketing.org/2013/09/phalcon-php-framework-on-hostgator-shared-hosting-account/

Thank you.

Hosting is an important thing. AMong it Shared Hosting is one of best source through which it is possible to run more than one website from same cPanel.

http://www.innovativehostingcorp.com/linux-web-hosting/

edited Jun '16

Dear Phalcon enthusiast and moderator @phalcon

i wanna to introduce cheap and realible shared hosting for phalcon framework, http://helloworldhost.com/

not only Phalcon supported, Yii2, laravel, etc has supported