2

I'm looking to offer my users beta access to test new features. I'm running my site using the Symfony framework.

Currently I have the following working configuration:

mysite.com:

<VirtualHost *:80>
DocumentRoot /var/www/html/mysite/current/web
ServerName mysite.com
ServerAlias www.mysite.com
<Directory "/var/www/html/mysite/current/web">
    AllowOverride None
    Order Allow,Deny
    Allow from All      

    <IfModule mod_rewrite.c>
        Options -MultiViews
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ app.php [QSA,L]
    </IfModule>
</Directory>
</VirtualHost>

I attempted to serve a beta version of my site with the following config:

<VirtualHost *:80>
DocumentRoot /var/www/html/mysite_beta/current/web
ServerName beta.mysite.com
<Directory /var/www/html/mysite_beta/current/web>
AllowOverride None
    Require all granted
    Allow from All

    <IfModule mod_rewrite.c>
        Options -MultiViews
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ app.php [QSA,L]
    </IfModule>
</Directory>
</VirtualHost>

This did not work and Apache served only the content from the second configuration but with 404 errors for the resources like css and js files that are included.

I'm not familiar enough with configuring Apache to get this working as I intend.

How can I get 2 different codebases of my site running on the same Apache server?

  • Your configuration shows no ` declarations is that right or did you just leave them out to post here ? – user9517 Nov 25 '16 at 18:53
  • They are left out, I'm using webmin to do the configuration and it gets left out in that interface. Sorry. I've edited the post to include them. – John the Ripper Nov 25 '16 at 19:01
  • Do you need separate instances of a DB server? If so, how are you handling that? – mbmast Nov 25 '16 at 21:52
  • I do have separate DBs with the configuration for each web instance pointing to the correct one. – John the Ripper Nov 25 '16 at 22:19
  • Id setup an nginx reverse proxy. Really simple to do. I serve multiple websites behind the same ip on the same port via nginx. – FreeSoftwareServers Nov 26 '16 at 06:11
  • Seems like that the problem is not on the virtualhost/apache config, have you verified that your site does really listen on beta.yoursite.com? – Orphans Nov 28 '16 at 14:30

2 Answers2

1

Verify that DNS resolves correctly for both mysite.com and beta.mysite.com. If Apache does not receive the HOST value in the header, it will use the first site that loaded.

Apache loads sites in alphabetical order.

Jeff W.
  • 521
  • 2
  • 7
-1

The configuration is fine but I can't see a

 NameVirtualhost *:80

Directive. Try to put it in the main configuration file

Diego Roccia
  • 348
  • 1
  • 6
  • I tried that and Apache tells me: `AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/apache2.conf:219` – John the Ripper Nov 25 '16 at 22:20
  • As of 2.4 this is now true: The NameVirtualHost directive no longer has any effect, other than to emit a warning. Any address/port combination appearing in multiple virtual hosts is implicitly treated as a name-based virtual host. Thanks for looking though. – John the Ripper Nov 25 '16 at 22:53
  • Why has the answer been downvoted? it was not specified which version of apache is being used – Diego Roccia Nov 28 '16 at 17:14
  • I did not downvote btw, however the tags do say it is apache 2.4. – John the Ripper Nov 28 '16 at 17:25