Two symfony projects on one server/domain

347 views Asked by At

I've created two independent symfony projects and I've moved them to my prod server, for example:

project1.example.com [/var/www/project1/web]
project2.example.com [/var/www/project2/web]

The problem is that when I open up the second address, then project1 is fired up. I checked /var/www/project2/web/app.php and seems it's properly executed, but for some reason, symfony loaders use /var/www/project1/ path. Of course the cache folders were cleared.

Any ideas how to diagnose the problem?

UPDATE

Apache config files:

/etc/apache2/apache2.conf
/etc/apache2/sites-enabled/project1.conf + /etc/apache2/sites-enabled/project2.conf

UPDATE 2

Strange thing, this morning the situation has reversed. Both addresses show site from project2 now. No config nor project files were modified.

1

There are 1 answers

5
Alvin Bunk On

You'll need to enable Virtual Hosting in Apache.

Take a look at my article on it, it should answer the question:

https://alvinbunk.wordpress.com/2016/11/21/apache-httpd-virtualhost-config/

If you need further help with that, you can always post another question. I use this all the time.


EDIT #2 - based on Apache 2 conf:

Suggest you combine SSL and HTTP VirtualHost ports like so, and also just have a single Directory directive to the web folder. There are other redundancies in the conf file. Please read some documents first about the Apache config files before asking questions.

<VirtualHost *:443 *:80>
    ...
    <Directory /var/www/project1/web>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
    ...
</VirtualHost>

For the Project2 problem, have you checked the logs in $APACHE_LOG_DIR to see what they show? I think logs are usually in /var/log; there's probably an httpd subdirectory with the httpd logs. You need to make sure there is an incoming GET request for project1.example.com.pl. If not, you'll need to check all your hosts files to see they are setup correctly.