Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shawnyv's avatar
Level 14

Hosting 2 sites on same server?

Hi all,

I'm running into an issue where I have 2 laravel sites (both Laravel 5.2) on the same server.

It looks like there's some contamination of the config settings - IE one site's error logs shows that its trying to access the 2nd sites database.

I've tried setting an artisan command to clear the config cache at the start of every page load, and ensured my cache prefix values are distinct, but to no avail.

Can anybody help me with this?

Thanks!

0 likes
6 replies
Snapey's avatar

There have been a few threads like this but I've not seen a definite solution. I happily run two and three sites on the same servers with no problem. I'm using apache and virtual hosts.

I assume the database server instance is the same, but with separate databases?

shawnyv's avatar
Level 14

Hi Snapey,

Yes, that's exactly correct. My database connection settings look the same in both sites, and in the .env file the only change comes to the DB_DATABASE variable (the host and password and username remain the same):

'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'forge'),
            'username'  => env('DB_USERNAME', 'forge'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],
bashy's avatar

Basically it's because when you have more than one site running and you use .env files, it doesn't know which file added the entries to the environment.

It's better to add these into a separate php-fpm pool (or similar for your setup e.g. Apache Virtualhost config).

Snapey's avatar

@bashy I've never encountered that being an issue? The environments should separate surely? It should not be possible for one host to poison the environment of another, either accidentally or maliciously?

zachleigh's avatar

I have three sites on a single production server and half a dozen on my dev box and have never had this problem. What host are you using?

shawnyv's avatar
Level 14

They're running on a local server on site utilizing Xampp (Not my first or third choice). Only about a dozen users for each service, and strictly limited to the internal network.

Please or to participate in this conversation.