Installing Symfony on a shared host at 1and1 with PEAR
These are the steps that I took and I think that it went rather well. Your mileage may vary.
- You have ssh access to the server.
- SSH to your host
- Create a local configuration file for PEAR in your home directory
pear config-create $HOME .pearrc
Change the rights of the file to avoid any http access
chmod 600 .pearrc
- Create the PEAR directory structure in your home directory
pear install -o PEAR
- 1and1 defaults to using php4 instead of php5. Need to do a couple of things to get php5 to be the default.
pear config-set php_bin /usr/local/bin/php5 export PHP_PEAR_PHP_BIN=/usr/local/bin/php5
- Create a bin directory in your home directory if it does not already exist. Create a link to php5 from php in your new bin directory.
mkdir ~/bin cd ~/bin ln -s /usr/local/bin/php5 php
- Modify your current PATH to include your new bin and pear directories
1. Add the symfony channel to PEAR
pear channel-discover pear.symfony-project.com
2. Install Symfony
pear install symfony/symfony
1. Add the following lines to your ~/.bash_profile so that the environment is setup when you login
export PHP_PEAR_PHP_BIN=/usr/local/bin/php5 export PATH=~/bin/:~/pear/:$PATH
Change the rights of the file to avoid any http access (if new)
chmod 600 .bash_profile
2. Once you have created your first project, you will need to create a link to the sf directory like this
ln -s ~/pear/data/symfony/web/sf ~/my_project_name/web/sf
3. You need to add the following to your project_name/web/.htaccess file:
# Force the use of PHP5 AddType x-mapp-php5 .php AddHandler x-mapp-php5 .php
4. Uncomment the following line in the same file:
# uncomment the following line, if you are having trouble # getting no_script_name to work RewriteBase /
5. Do not forget to fill ~/my_project_name/config/config.php with correct values. The symfony lib files are in YOUR_ABSOLUTE_HOME_DIR/pear/php/symfony and the symfony data files are in YOUR_ABSOLUTE_HOME_DIR/pear/data/symfony (note that you must not use the "~" here for your home directory, as it does not always mean your home, depending on the user running the script).
You may have routing problems with applications with no_script_name set to off (backend.php for instance). 1and1 servers do not set SCRIPT_NAME with the correct value (which should be the script name), and add the routing parameters to SCRIPT_NAME. So a request like "http://domain.com/test.php/tralala will set SCRIPT_NAME to "test.php/tralala" instead of "test.php"
Here is one solution, which is not really proper, but it works :
1. Backup sfWebRequest.class.php, edit it, and find the line with SCRIPT_NAME :
cd ~/pear/php/symfony/request cp sfWebRequest.class.php sfWebRequest.class.php.backup vim sfWebRequest.class.php /SCRIPT_NAME
2. Change :
return isset($pathArray['SCRIPT_NAME']) ? $pathArray['SCRIPT_NAME'] : (isset($pathArray['ORIG_SCRIPT_NAME']) ? $pathArray['ORIG_SCRIPT_NAME'] : '');
return isset($pathArray['ORIG_SCRIPT_NAME']) ? $pathArray['ORIG_SCRIPT_NAME'] : (isset($pathArray['SCRIPT_NAME']) ? $pathArray['SCRIPT_NAME'] : '');