Development

HowtoMultipleSFProjectsLocal

You must first sign up to be able to contribute.

Version 5 (modified by tomas, 9 years ago)
Typo: /etc/host -> /etc/hosts

How to "simply" use multiple SF Projects on one local machine MyWay

Introduction

When I started my first own project (not that long ago) I always looked at the sources Fabien and the other developers published f.e. the admin_generator or askeet.

Therefore I downloaded the sources and found that symfony runs best when reached from a simple domain like (http://askeet/ and http://phpmyadmin and http://mysymfony01 a.s.o). Installing in subdirectories can give problems with the links to the images of f.e. the dtree.js

But how can I intersperse my Apache to take several domains and redirect them to the sf_directories as DocumentRoot?

Solution

First, like described in the book we add different vhosts to our apache2 in /etc/http/vhost.d and call them something like

  • phpmyadmin.conf
  • askeet.conf
  • mysymfony01.conf

Within these conf's, we write nearly what is suggested in the Howto configure a webserver chapter of the symfony book, but slightly different because there is not only one loopback device. Try it, look at http://127.0.0.2 or http://127.0.1.120, all loop back to your own Apache2.

Therefore we now setup our VirtualHost (here Apache installed with mod_userdir) like:

<VirtualHost 127.0.0.2:80>
  ServerName askeet
  DocumentRoot "/home/me/public_html/askeet/web"
  DirectoryIndex index.php
  Alias /sf /$data_dir/symfony/web/sf

  <Directory "/home/me/public_html/askeet/web">
   AllowOverride All
   Allow from All
  </Directory>
</VirtualHost>

the next project of course gets the 127.0.0.3

Then we edit our /etc/hosts file which should look like:

127.0.0.1         localhost
127.0.0.2         askeet
127.0.0.3         anotherproject

For Windows users: The hosts file is located at X:\WINDOWS\system32\drivers\etc\hosts where X is the letter of the drive windows is installed.

After restarting Apache now we can access our projects with

DONE