Tuesday, April 01, 2008

deploying a Symfony 1.0 project to a shared hosting envirnoment without Symfony installed

Deploying 1.0 To A Shared Host

This page describes a method of deploying a Symfony 1.0 project to a shared hosting envirnoment without Symfony installed.


In order for this method to work, you need to meet the following conditions:

  • A Shared Host with PHP5
  • A functional copy of the project you plan to deploy in a local environment with Symfony 1.0 installed
  • An FTP account to the host you plan to deploy to.

Preparing Your Local Project

Several things need to be dealt with before beginning to upload.

  1. Update Symfony - Make sure that you're using the latest update of Symfony 1.0 (at the time of this writing the most recent update is 1.0beta1). For example, if you are using a pear install of Symfony 1.0beta1 on linux, you might execute this command:
    sudo pear upgrade symfony/symfony-beta
  2. Update Project - If you've recently updated your symfony install, be sure to update the project for the new version:
    symfony upgrade 1.0
  3. Freeze Project - Now comes the easy part. When you freeze a project, like we're about to do, Symfony automatically packages the current pear libraries into the project directories and updates the configuration to point to these internal libraries. This tool has several purposes, of which easing deployment is one of the most useful. So, just issue the command in your root project directory, and watch the magic happen:
    symfony freeze

You will then see a long list of things which Symfony is doing, most of which involve copying files to their new locations. Most of these will be in the lib/ and data/ directories, but there are a few in other places, such as the web/ directory.

Preparing Your Host Space

Directory Structure

Most shared hosting companies provide you with a base directory where you may upload your files. A standard layout for the subdirectory structure looks like this:


There may be other folders, but they are not important to us.

Uploading the Files

Uploading the files is really quite easy, provided you know how to use an FTP client. If not, I would suggest you go read up on them, as they are very useful tools.

All you need to do is upload the following directories to the root folder of your webspace (Note: Do not upload the files into your public_html or similar folder. This is a severe security risk'''):

+-/plugins (Optional, depending upon whether you have any plugins installed)

The next thing you need to do is upload the files in your project web/ directory into your remote public_html/ directory, or whatever directory you have that fulfills the function of holding your publically-viewable files.

/web/*    =>    /public_html/


Now that you've uploaded the files, you need to ensure that the permissions of certain folders didn't get messed up while uploading.

symfony fix-perms
  • /cache : This folder should have world-writable permissions (777)
  • /log : This folder should have world-writable permissions (777)
  • All others: The other folders and file should be world-readable and executable (755)


There are a few other things you might want to do now that you're mostly finished.

Dev Controllers

I would definitely recommend that you deleted the dev controllers (/public_html/*_dev.php), since they are not needed and have the potential to deliver unwanted information to anyone attempting to hack your website.

Plugin Web Directories

Depending upon the method of installing your plugins and the platform you have developed your project on, the plugin web/ directories may need attending to. Generally if they worked on your local system, they'll work on your host, but if you encounter broken images and an absence of certain javascript files and stylesheets, then you may need to fix this. You have two options:

  1. If you are on a host that supports symlinks, you can create symlinks from the main public_html directory to the plugin web directories.
  2. The universal method of fixing a problem like this is to simply copy the contents of the plugin web/ directories into your main public_html/ directory.


Problem with stylesheet (css)

If the link to stylesheet doesn't work, add the following line to index.php:


Based on this thread (OVH context).


If you experience problems with this, simply ask on the forums or mailing list and you will most likely get an answer soon.

No comments: