Recently, I was working on a project to setup a new website on a 1 & 1 shared host. Shared hosts are a cheap alternative to VPS and managed servers but they come with a mixed bag of restrictions that limit your ability to configure the server. I was looking for a host for under $10/month that offered SSH access and had a typical LAMP setup. This is how I configured the rest.
Update 10/9/2009: Please read my updated article on setting up a 1&1 Shared Host.
To use PHP 5 by default, add the following line to the .htaccess file under the htdocs folder.
AddType x-mapp-php5 .php
Need to setup custom PEAR modules? No problem, just follow this guide. Contrary to the guide, however, I would install PEAR into a
~/opt subfolder so that you have a place to install other applications and libraries in the future. Also, add the
~/opt folder to your list of “Protected Directories” using 1 & 1’s config panel.
Adding PEAR to PHP’s
include_path was another challenge. I found that the best way to do this is inside the PHP code by using the following command (messing with
php.ini files in every directory of your project is too much of a hassle).
1&1 keeps their mySQL servers behind a firewall which makes it impossible to access them using local client tools. The only way in is via SSH using the CLI or using web based config tools like phpMyAdmin. I was also unable to pick my own database name or create my own account (1&1 creates one for you). This took me a while to accept but I had to give in eventually.
As a consequence, when configuring PHP applications such as WordPress, you have to set the database settings to the cryptic database name and login account created by 1&1. Also, remember to change the host name from
"localhost" to the host name provided. 1&1 actually offers a guideto setup WordPress although they state that support for this 3rd party software is not provided.
Configuring a Subversionrepository was a bit more of a challenge but luckily it is not impossible. First, login to the shared host via SSH and download the latest Subversion source code from their site. I created a local
~/tmp folder under
htdocs for this. Note that we will need to get the code for the dependency libraries as well because 1&1 does not have them installed.
> wget http://subversion.tigris.org/downloads/subversion-1.4.5.tar.gz
> wget http://subversion.tigris.org/downloads/subversion-deps-1.4.5.tar.gz
> tar -xzvf subversion-1.4.5.tar.gz
> tar -xzvf subversion-deps-1.4.5.tar.gz
At this point we have the folder
~/tmp/subversion-1.4.5 containing all the needed source code. We need to configure the project to install it into the
~/opt/svn folder, build/compile the code, and install it.
> cd ~/tmp/subversion-1.4.5
> ./configure --prefix=/homepages/xx/xxxxxxxxxx/htdocs/opt/svn
> make install
If all goes well (which it should), the last thing to do is to include the compiled svn binary into our path so that we can issue the
svn command from any directory. It is best to set the
$PATH variable in the
.bash_profile file so that the setting gets applied every time that you log in.
> echo 'export PATH=$PATH:$HOME/opt/svn/bin' >> ~/.bash_profile
To test our configuration, just check the version of the SVN binary (remember to log out and back in to make sure the
$PATH gets set… or just do it once manually). We should also cleanup the temp files that we created and create a new Subversion repository while we are at it.
> svn --version
> rm ~/tmp/subversion* -r
> svnadmin create ~/opt/svn/repos
Note that we will only be able to connect to our Subversion repository using the svn+ssh protocol because we will not be able to get an actual Subversion server setup. TortoiseSVN is a great Windows tools for connecting to your repository. However, for this to work, we also need to set the
$PATH in the
.bashrc file (we only setup the
.bash_profile so far). This guide explains why.
Your mileage with other Shared Hosting providers may vary. Hope this helps…