Using the symfony framework with cPanel based shared hosting

Posted on Sunday, 16th December 2007.
WebLincs.co.uk now offers a range of affordable web hosting packages featuring the use of our installation of the symfony framework.

This article is only useful if the Symfony framework is installed on the server in question. If this is not the case then we suggest that you "freeze" the project on your development environment and FTP it up to your shared hosting account. If you wish to install the Symfony framework on a shared hosing environment, please read this article.

Developing symfony projects usually require that you have access to httpd (Apache) configurations so that you may modify the virtual host to include the symfony sf/ directory from the symfony installation. This is as well as changing the DocumentRoot, pointing it to the web/ directory of your symfony project instead of public_html (the default web root of cPanel accounts).

Overcoming this issue must be done in a way that does not tamper with the way cPanel functions, namely modifying httpd.conf to suit the symfony directives. This could cause cPanel to become corrupt, running the risk of it crashing.

To do this, we use symlinking via the bash terminal over SSH. Symlinking the directories means that cPanel's httpd configuration is not changed. Please see below for the commands to do this. Let's say that we have set up the following account in cpanel, "/home/example", and that you're creating a new

symfony project, "my_app", for this user - the steps to take are as follows:

WARNING: These commands require you to completely delete the "public_html" directory in your shared hosting account.

  1. [example@server example]# mkdir webapps

  2. [example@server example]# mkdir webapps/my_app

  3. [example@server example]# cd webapps/my_app

  4. [example@server my_app]# symfony new my_app

  5. [example@server my_app]# symfony app my_app frontend

  6. [example@server my_app]# cd ~/

  7. [example@server example]# rm -rf public_html

  8. [example@server example]# ln -s webapps/my_app/web public_html

  9. [example@server example]# cd public_html

  10. [example@server public_html]# ln -s /usr/local/lib/php/data/symfony/web/sf/ sf

...And you're done!

Please note that the last command links the /sf directory to /sf in your application's /web directory. This path must relate to your particular installation of symfony.

Back to Web Development Articles.