= 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 [http://www.symfony-project.com/content/book/page/web_server.html 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: {{{ ServerName askeet DocumentRoot "/home/me/public_html/askeet/web" DirectoryIndex index.php Alias /sf /$data_dir/symfony/web/sf AllowOverride All Allow from All }}} 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 * http://askeet * http://phpmyadmin * http://anotherproject == Extended Solution == If you have a lot of projects sharing the same host configuration, there is an even easier way to access them. Apache can be configured for something called [http://httpd.apache.org/docs/2.0/en/vhosts/mass.html Dynamically Configured Mass Virtual Hosting]. * Create the directory {{{/home/me/public_html/sym}}} * Like described above create a new vhost file and include it. * Be sure that {{{log_config_module}}} is loaded. This is my file {{{vhost.sym.conf}}}: {{{ # ### # Configuration file for mass hosting # LogFormat "%V %h %l %u %t \"%r\" %s %b" symcommon NameVirtualHost 127.0.0.4:80 Listen 127.0.0.4:80 VirtualDocumentRoot "/home/me/public_html/sym/%1/web" CustomLog "logs/sym.access_log" symcommon ErrorLog "logs/sym.error_log" AllowOverride All Allow from All DirectoryIndex index.php Alias /sf /$data_dir/symfony/web/sf AllowOverride All Allow from All }}} As you can see, this is almost the same configuration as above. The main difference is the use of [http://httpd.apache.org/docs/2.0/en/mod/mod_vhost_alias.html#virtualdocumentroot VirtualDocumentRoot] to locate the document root. Restart your Apache to load the configuration. Remeber that you can use {{{httpd -S}}} to let Apache show he settings parsed from the configuration files. Now you can set up new projects '''without restarting apache'''. The only manual step left is configuring your {{{/etc/hosts}}} for name resolution. For testing we will set up two projects: Change to the {{{/home/me/public_html/sym/}}} directory. This is the root for the new projects. {{{ mkdir first cd first symfony generate:project first symfony generate:app frontend cd .. mkdir second cd second symfony generate:project second symfony generate:app frontend }}} Modify your {{{/etc/hosts}}}: {{{ 127.0.0.4 first.sym 127.0.0.4 second.sym }}} Point your browser to: * http://first.sym/ * http://second.sym/ This configuration is not a replacement for the solution described above. They perfectly live side-by-side. I use the ''one-config-for-all-setup'' for quick setups, e.g. testing of new plugins in a clean environment and the ''one-config-per-host-setup'' if I need special configuration settings. '''DONE'''