Symfony: muchos proyectos en muchos dominios diferentes

I'm learning Symfony right now. I created 2 Symfony projects with 2 different domains. Nevertheless, my second domain points to the first, and don't know why.

I'm following this tutorial, the famous jobeet: http://www.symfony-project.org/jobeet/1 ... rine/en/01

Notice my configurations:

My /etc/apache2/httpd.conf

ServerName localhost

#From the symfony tutorial "jobeet"
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080

# This is the configuration for your project
<VirtualHost 127.0.0.1:80>
 ServerName www.jobeet.com.localhost
 DocumentRoot "/home/lola/sfprojects/jobeet/web"
 DirectoryIndex index.php
 <Directory "/home/lola/sfprojects/jobeet/web">
    AllowOverride All
    Allow from All
 </Directory>
 Alias /sf /home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
    AllowOverride All
   Allow from All
 </Directory>
</VirtualHost>


#Another symfony tutorial
NameVirtualHost 127.0.0.1:8081

<VirtualHost 127.0.0.1:80>
ServerName www.tutorial.com.localhost
DocumentRoot "/home/sfprojects/tutorial/web"
  DirectoryIndex index.php
  <Directory "/home/sfprojects/tutorial/web">
    AllowOverride All
    Allow from All
  </Directory>
  Alias /sf /home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf
  <Directory "/home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

Aviso that I'm listening to 8081 puerto en el tutoriales domain. I tried the permutation of VirtualHost 127.0.0.1:80 and VirtualHost 127.0.0.1:81. Neither worked. (really don't know which use)

Mi / etc / hosts:

#From the symfony tutorial
127.0.0.1 www.jobeet.com.localhost

#From ANOTHER symfony tutorial
127.0.0.1 www.tutorial.com.localhost

After that I restarted Apache.

Ahora, cuando lo haga: http://www.jobeet.com.localhost/frontend_dev.php/ I go to my Jobeet tutorial things, PERO Cuando lo hago http://www.tutorial.com.localhost/frontend_dev.php/ I TAMBIÉN go to the Jobeet page. I should go to the one containing the tutoriales parte.

¿Por qué es no working??!

preguntado el 01 de febrero de 12 a las 14:02

it sounds more like a webserver (apache) problem.... -

It was my mistake. I will post after 8 hours -because my reputation in less than 100- So, for tomorrow, I will put the answer. Short one: NameVirtualHost must be called ONE time, like NameVirtualHost:80 -

May I suggest, if you're learning Symfony for the first time, that you learn Symfony2 instead. Symfony 1 will no longer be supported as of a year from now. -

Thank you! In fact I'm learning both! Never the less, the projects of the company I'm working for are in 1.4. They do not want to migrate to 2 because the fears of breaking the system (is HUGE, and gives services to half a continent). So, I have no option right now :/ -

2 Respuestas

Bien:

In /etc/apache2/httpd.conf is enough with:

 NameVirtualHost 127.0.0.1:80

I repeated this command when creating the other ServeName (tutoriales). Maybe that was the conflict. I left all in port 80. Now it resolve right.

So, this is the final /etc/apache2/httpd.conf:

ServerName localhost

NameVirtualHost 127.0.0.1:80

# This is the configuration for your project
<VirtualHost 127.0.0.1:80>
 ServerName www.jobeet.com.localhost
 DocumentRoot "/home/lola/sfprojects/jobeet/web"
 DirectoryIndex index.php
 <Directory "/home/lola/sfprojects/jobeet/web">
    AllowOverride All
    Allow from All
 </Directory>
 Alias /sf /home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
   AllowOverride All
   Allow from All
</Directory>
</VirtualHost>


#Another symfony tutorial
# DO NOT REPEAT NameVirtualHost 127.0.0.1:80 --------> ****HERE: do not repeat this****

<VirtualHost 127.0.0.1:80>
ServerName www.tutorial.com.localhost
DocumentRoot "/home/sfprojects/tutorial/web"
  DirectoryIndex index.php
  <Directory "/home/sfprojects/tutorial/web">
    AllowOverride All
    Allow from All
  </Directory>
  Alias /sf /home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf
  <Directory "/home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf">
    AllowOverride All
    Allow from All
  </Directory>
 </VirtualHost>

The /etc/hosts (or in /etc/apache2/sites-avaiable for debian) is the same.

I can access to www.jobeet.com.localhost and www.tutorial.com.localhost

Sorry, it was my misconfiguration.

Respondido 02 Feb 12, 17:02

  1. A common mistake is to have disabled the virtual host module for apache, for enable it try: sudo a2enmod virtualhost

  2. put your vhost conf in /etc/apache2/sites-available/name-file-with-vhost-conf

  3. all virtual host must be enabled, with sudo a2ensite name-file-with-vhost-conf

  4. apache2 must be reloaded sudo service apache2 reload

usted puede probar esto github/rokemaster/virtual_hosts is all steps in one script

Respondido 03 Feb 12, 09:02

there would be a difference doing it in the /sites-aviables rather que en el /etc/hosts? - usuario935375

/sites-available/is a place where apache read configuration about vhost and /etc/hosts file is a static DNS for the OS and is necesary for the properly function of virtual host - rkmax

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.