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

RuiCosta's avatar

Deploy multiple Laravel 5.4 projects on the same Apache Server

Hi,

I have a Linux Server (CentOS) with Apache installed. I want to have multiple laravel projects on the same server to get everything working like this:

|-- /var/www/html

|-- project1 |-- app |-- bootstrap |-- public |-- index.php |-- ...

|-- project2 |-- app |-- bootstrap |-- public |-- index.php |-- ...

|-- project3 |-- app |-- bootstrap |-- public |-- index.php |-- ...

At the end i should have something like:

  • www.mysite.com/project1
  • www.mysite.com/project2
  • www.mysite.com/project3

Questions:

  1. What i need to setup on httpd.conf?
  2. What i need to setup on .htaccess?
  3. What i need to setup on index.php?

Note: I want to maintain exactlly the same structure that i have above.

0 likes
5 replies
Snapey's avatar

you will find it much easier if you use subdomains. I know you say you want it exactly as specified but then you have to be really careful about these not being in the root directory

using dns you can create

  • project1.mysite.com
  • project2.mysite.com
  • project3.mysite.com

then you can have truly independent installs

RuiCosta's avatar

Yes i know but i have no chance. I really need to maintain that structure because i can’t create new dns’s.

Snapey's avatar

I honestly don't know how it can be done, but make sure you put your framework on the private side of www/html

What I mean is;

/var
    /www
        /html             (apache Document Root)
             /project1    (the contents of public from project 1)
             /project2    (       "          "         project 2)
             /project3    (       "          "         project 3)
        /project1         (project 1 Laravel framework)
        /project2         (project 2 Laravel framework)
        /project3         (project 3 Laravel framework)

RuiCosta's avatar

Ok ... i found a solution. Basically i've changed my ".htaccess" to:

RewriteEngine On

RewriteBase /project1/

RewriteRule ^(.*)$ public/$1 [L]

And on my web.php i created aroute::group like:

Route::group(['prefix'=>'project1'], function() {

... here i placed my routes ...

}

But now i'm getting some problems with CSS and JS files that are not beeing loaded.

When i open the developer mode on the browser i can see that the browser is looking for the files on: • www.mysite.com/css/xpto.css

and i need that it looks to:

• www.mysite.com/project1/css/xpto.css

The same happen also for other assets like images and so one.

What should i change in order to get it working without change all the images, js and css paths?

Please or to participate in this conversation.