Installing a sf project on a shared host

Posted by alecs on 2009-11-27

First of all we have to consider the fact that we might have to install a new project to a shared host.

Assuming that your hosting provider allows you to see your home dir (most servers are powered by cpanel), then you will have a file structure like:

  • access-logs
  • etc
  • mail
  • public_ftp
  • public_html
  • tmp
  • www
  • [some .hidden files ]

Having this structure, you'll have to upload your web visible part of the project to "public_html" folder. This may consist of the content of your web directory:

  • css
  • images
  • js
  • sfAdminDashPlugin
  • sfFormExtraPlugin
  • sfJqueryLibsPlugin
  • sfPropelPlugin
  • sfProtoculousPlugin
  • sfSimpleBlogPlugin
  • uploads
  • index.php
  • backend.php
  • some other files

Enough with talking ... let's make this project run.

As said before, you upload your web/ content to public_html folder. After you have done that, then create a folder in your home folder, (name it whatever you want, but i will choose sf_project ).

Now, i will have a new folder called sf_project in the first list that i have gave in this post. Inside this folder you have to upload your symfony freezed project.

After the upload is completed, go and edit your /sf_project/config/ProjectConfiguration.class.php and make it contain inside the setup method:

$this->setWebDir('/home/YOUR_CPANEL_USERNAME/public_html/');

or alternativelly

$this->setWebDir('/THE/FULL/PATH/TO/YOUR/DIRECTORY/CALLED/public_html/');

I haven't tested, but i think that will work as well

$this->setWebDir(dirname(__FILE__).'/../../public_html/');

After you have done this, make sure that your "cache" & "log" folders are writeable by the apache.

Now, go to the HOME_DIR/public_html/ and edit your index.php file from:

require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php'); $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod',false); sfContext::createInstance($configuration)->dispatch();

To:

require_once(dirname(__FILE__).'/../sf_project/config/ProjectConfiguration.class.php'); $configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'prod',false); sfContext::createInstance($configuration)->dispatch();

Check "require_once" directive.

As the web folder is on the same lever with sf_project, you will have to edit the "require_once" from "../" to "../sf_project/".

Hope this link will help you out.