How to configure Apache for two symfony projects in one domain (without using subdomains)?

I am trying to configure Apache for different symfony projects (each with its own framework installation) in the same domain, but I cannot get it to work with folders.

This is what I would like to have:

  • mydomain.com/projectone/
  • mydomain.com/projecttwo/

I can get it to work using subdomains, but for me this is not the preferred solution because I have crazy subdomains:

  • projectone.mydomain.com
  • backend.projectone.mydomain.com
  • projecttwo.mydomain.com
  • backend.projecttwo.mydomain.com

I use this configuration in Apache to work with subdomains:

<VirtualHost 127.0.0.1:8080> ServerName projectone.mydomain.com DocumentRoot "/home/projectone/web" DirectoryIndex frontend.php <Directory "/home/projectone/web"> Options -Indexes IncludesNOEXEC FollowSymLinks -MultiViews AllowOverride None Allow from All RewriteEngine On # we check if the .html version is here (caching) RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f # no, so we redirect to our front web controller RewriteRule ^(.*)$ frontend.php [QSA,L] </Directory> Alias /sf /home/projectone/lib/vendor/symfony/data/web/sf <Directory "/home/projectone/lib/vendor/symfony/data/web/sf"> AllowOverride All Allow from All </Directory> </VirtualHost> 

Any idea on how to get the folders resolved?

Thanks in advance, Eneko

+6
apache symfony1 virtualhost
source share
3 answers

I do this all the time. Here's the corresponding Apache configuration. I also created custom error handlers for every symfony application.

  # make sure your symfony install dir is available <Directory "/var/www/symfony1.4"> AllowOverride All Allow from all </Directory> # each app under http://mysite/myapp gets a section like this Alias /myapp/sf "/var/www/symfony1.4/data/web/sf" Alias /myapp "/var/www/vhosts/myvhost/sf_apps/myapp/web" <Directory "/var/www/vhosts/myvhost/sf_apps/myapp/web"> AllowOverride All Allow from all ErrorDocument 404 /myapp/default/error404 ErrorDocument 500 /myapp/myThemePlugin/errors/error500.php </Directory> 

You also need to hack this line in the web/.htaccess file.

 # uncomment the following line, if you are having trouble # getting no_script_name to work RewriteBase /myapp 
+2
source share

I tried this code and it seemed to work. Since I have not tested it, I am not sure if this is a bug, but it may be a hint to you.

 <VirtualHost 127.0.0.1:8088> Alias /badger /home/amqs/proyectos/sales/nuevo/salesprime/web DocumentRoot "/home/amqs/proyectos/sales/nuevo/salesprime/web" DirectoryIndex frontend_dev.php <Directory "/home/amqs/proyectos/sales/nuevo/salesprime/web"> AllowOverride All Allow from All </Directory> Alias /sales /home/amqs/proyectos/sales/salesprime2/web DocumentRoot "/home/amqs/proyectos/sales/salesprime2/web" DirectoryIndex frontend_dev.php <Directory "/home/amqs/proyectos/sales/salesprime2/web"> AllowOverride All Allow from All </Directory> </VirtualHost> 
+1
source share

You can use the setWebDir method in ProjectConfiguration to specify a unique web directory that will be used in each project. This will allow you to place project files (applications, config, lib, plugins, etc.) in any directory you want (/ home / projectone), when moving files usually on the Internet / to a completely different place (/ home / MYDOMAIN / web / projectone). You have the option to configure the entire project web directory from the root ProjectConfiguration in config/ProjectConfiguration.class.php :

 class ProjectConfiguration extends sfProjectConfiguration { public function setup() { $this->setWebDir('/home/mydomain/web/projectone'); } } 

or if you want each of your applications to have a different web directory (/ projectone / for front-end and / projectone / backend / for internal), you can set the web directory from each of the application configurations in apps/myapp/config/myappConfiguration.class.php :

 class myappConfiguration extends sfApplicationConfiguration { public function configure() { $this->setWebDir('/home/mydomain/web/projectone'); } } 

Hope this helps.

0
source share

All Articles