How to install Symfony and deploy your project on a shared hosting

I decided to write an updated tutorial for several reasons. First is that PHP5 is now used by default by most hosting providers. Second, there are several restrictions that exist on shared hosting platforms that which were not addressed in the earlier tutorials. Finally, with the release of Symfony 1.2 there might arise a need to use PDO PHP extension, which is not enabled by default on most shared hosting accounts.

Install PEAR

First we need to install PEAR locally. To do this we need to download the 'go-pear.phar' file from If you have 'wget' enabled all you need to do is type this:


Alternatively you can just save the file to your local machine and then upload it to your hosting account.

To actually install PEAR run:

php go-pear.phar

To make using pear easier create an alias for the PEAR command. Type:

ln -s /home/user/pear/bin/pear mypear

PEAR has a hard coded 8Mb memory limit which is not enogh to download and install Symfony. Many hosting providers set a cap on memory allocation to processes at 16Mb which is still not enough. So to do the job we need to both boost PEAR's maximum memory size and split the Symfony package download from the installation process.

To set PEAR memory to 16Mb we need to edit the pear command file. Type:

pico /home/user/pear/bin/pear

Scroll down to the very last line that starts with 'exec' and after '$INCARG' add this:

-d memory_limit=16M 

Save the file and exit. (Ctrl+O to save, then Ctrl+X to exit.)

Install symfony

As discussed first we need to download the Symfony package and then install it from a locally saved file.

Discover Symfony channel:

./mypear channel-discover

Download the package:

./mypear download symfony/symfony-1.2.2

Install Symfony:

./mypear install symfony-1.2.2.tgz

Symfony command now available at /home/user/pear/bin/symfony. To test run:

/home/user/pear/bin/symfony -V

This should display the version number of currently installed Symfony package.

Deploy project

Upload your project files to your '/home/user/ directory'. You can use Symfony's deploy command or rsync.

In order for your project to work you need to set correct path to Symfony's files. If you hosting provider allowes you to change the document root of your account, ask the tech support to change it to '/home/user/project/web'. If changing document root is not allowed you need to tweak your project settings. We will assume you need to use '/home/user/public_html/' as you document root for the project.

Edit the 'ProjectConfiguration.class.php' file:

pico /home/user/project/config/ProjectConfiguration.class.php

Find a line that requires the 'sfCoreAutoload.class.php' file and change the path to the file so the line looks like this:

require_once '/home/user/pear/share/pear/symfony/autoload/sfCoreAutoload.class.php';

To change the document root directory of your project in the 'ProjectConfiguration::setup()' function add the following:


Save and exit.

Now replace your current 'public_html' directory with your project's 'web' directory:

cp -R /home/user/project/web/ /home/user/public_html/

Edit the 'index.php' and any other controller files to specify the correct path to 'ProjectConfiguration.class.php'. This means replacing this line:


with this:


You will probably need to edit the .htaccess file to make sure that .php files are interpreded by PHP5 and not by PHP4 which will lead to errors. Type:

pico /home/user/public_html/.htaccess

Add this line at the beginning of the file:

AddHandler application/x-httpd-php5.php

Change 'php.ini' settings

If you are planning to use Propel with Symfony 1.2 you need to use a custom 'php.ini' file, generally it might also be a good idea regardless.

Copy the 'php.ini' file to your document root by typing:

cp /usr/local/lib/php.ini /home/user/public_html/php.ini

You can check what Symfony has to say about your current PHP configuration by running Symfony's 'check_configuration.php' file. To do that type:

php /home/user/pear/data/symfony/bin/check_configuration.php

For example you might set these to "off" like so:

short_open_tag = Off
magic_quotes_gpc = Off

To enable PDO extension required for Propel add these lines to custom 'php.ini' file:
This will only work if your hosting provider has these extensions installed.

Change 'rsync_exclude.txt'

If you are using rSync to deploy your project you need to edit your 'rsync_exclude.txt' file, otherwise all the changes you made on the server will be lost. Add these lines to the file:


You might also need to add any controller files you changed on the server.

That's it! Your project should be running now.


© 2003 — 2017 Akinas
Все права защищены