문제

I have a symfony2 project running in my company's server (Debian for production, Ubuntu for development). We want to host another symfony2 web site in the same server, and we would like to keep both projects separated because they are not related each other and use different CSS styles.

I have defined two virtual hosts with subdomains pointing to each project's folder, but I can't keep both sites running together. It only runs the first one I load in a browser, and the second one shows this error: ClassNotFoundException: Attempted to load class "RecAicragPromocionesBundle" from namespace "RecAicrag\PromocionesBundle" in /var/www/promociones/app/AppKernel.php line 19. Do you need to "use" it from another namespace?

It doesn't matter which one I load first, second one shows that error. I think there's a shared configuration somewhere, but I can't find how to solve it.. And I also can't find any example of how to host two projects in the same host.

If I can have two different configurations and CSS styles, I can consider keeping both sites in the same project, but I would prefer to keep them in different places.

My apache conf:

<VirtualHost *:80>
        ServerAdmin carlos@xxx.com
        ServerName localhost
        DocumentRoot /var/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
        ServerAdmin carlos@xxx.com
        ServerName intranet.localhost
        DocumentRoot /var/www/intranet/web/
        <Directory /var/www/intranet/web/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>
<VirtualHost *:80>
  ServerName promociones.localhost
  ServerAdmin carlos@xxx.com
  DocumentRoot /var/www/promociones/web/
  <Directory /var/www/promociones/web/>
        RewriteEngine On
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
  </Directory>
</VirtualHost>

First project: app/config/routing.yml

xxx_intranet:
    resource: "@XxxIntranetBundle/Resources/config/routing.yml"
    prefix:   /

src/.../Resources/config/routing.yml

intranet_consultas:
    pattern: /consultas
    defaults: { _controller: XxxIntranetBundle:Generico\Consultas:index }

intranet_consulta_articulo:
    pattern: /consultas/articulo/{codigo}
    defaults: { _controller: XxxIntranetBundle:Generico\Consultas:articulo }

......

xxx_intranet_Annotations:
    resource: "@XxxIntranetBundle/Controller/"
    prefix:   /
    type:     annotation

Second (new): app/config/routing.yml

rec_xxx_promociones:
    resource: "@RecXxxPromocionesBundle/Resources/config/routing.yml"
    prefix:   /

src/.../Resources/config/routing.yml

rec_xxx_promociones_homepage:
    pattern:  /hello/{name}
    defaults: { _controller: RecXxxPromocionesBundle:Default:index }

I have tried setting "host" parameter in routing.yml and nothing happens, still the same.

도움이 되었습니까?

해결책

Do you have APC enabled on your server?

If you do, this is likely to be the problem. Symfony stores a class cache in APC, which by default has the same key name.

This means that whichever the first application it is that you access after restarting Apache, is the one that populates the class cache. The second application will then try to use the same class cache, and will break fairly horribly.

You should just be able to change the class cache name to be application-specific - I believe it's in app/autoload.php - and that should solve your issue. If not, then post back :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top