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

marcor's avatar

Deploying laravel project on server

Hi guys,

I have a Laravel project designed locally and I want to deploy it on a remote server so that all my agents can use it. I use Laravel 5.4 with windows 7 and wamp as a php server (must use these!!)

On the server, I modified the hosts file under C:\Windows\System32\drivers\etc\hosts by adding localhost MyProject

and modified the httpd hosts for Apache under C:\wamp\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf:

<VirtualHost *:80>
    ServerName MyProject
    DocumentRoot c:/wamp/www/MyProject/public
    <Directory  "c:/wamp/www/MyProject/public/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
    </Directory>
</VirtualHost>

Now on the server, if I use http://MyProject/anyRoute it works.

But from the agents workstations calling this url is not feasible!! since you have to direct it to the server!

I have a lot of agents and it's not feasible to change something on their workstations for each project I deploy.

Can someone please shed the light on this matter: how do I deploy a laravel project on server so my agents can use it?

0 likes
18 replies
topvillas's avatar

Don't try and set up hosting if you don't know what you're doing. You're opening yourself up for a world of hurt.

Where is your server located?

marcor's avatar

Hi topvillas, we are actually aware of that, and I have already taken all the required security measures with our engineers and architects. My server is located on another location. What other alternatives than hosting do I have? Moreover, how to make the hosting work?

Thyrosis's avatar

I think what topvillas meant was to leave hosting to hosting professionals, don't try to do it yourself if you havent got a clue what you're doing. Because - and feel free to correct me if I'm wrong - but that's what it sounds like now.

For instance, have you registered a domain name and pointed the DNS to your server IP? Is that IP accessible from the outside world?

If you're not using a domain, you should change the local host file on all your agents devices to point 'MyProject' to your server's IP address.

There are a few companies out there running fairly decent Windows VPS servers. You're talking about many agents, so Im guessing this is a business project you're running. In that case I would suggest looking for a hosting provider which suits your needs.

marcor's avatar

Hi Thyrosis, thank you for your answer. I actually understood topvillas comment and I very well understand hosting. But this is the first time we do it with laravel! we have registered a domain name and it's accessible only from our agents IPs.

Laravel's projects are not like normal php projects, since for example locally, it won't work without a php artisan serve!

jaydeluca's avatar

Laravel's projects are not like normal php projects, since for example locally, it won't work without a php artisan serve!

This is not correct. I think you are a bit confused as to what a server is or how it works, which is why I agree with the above posters who say that maybe you should consider buying hosting instead of trying to run and maintain your own hardware.

But if you insist, you have a lot more homework to do. We need more information on the server itself before we can tell you how to make it work. Is it Linux? Is it running apache? nginx? have you opened up ports allowing outside traffic?

Thyrosis's avatar

@marcor, that's good to hear, sorry I misjudged your question/reply then.

Laravel's projects are not like normal php projects

That's not completely true. Of course Laravel are like normal PHP projects. Laravel IS a normal PHP project.

php artisan serve is a cool feature, but if you're developing locally with WAMP, you don't need it at all. As long as you put all your project's Laravel files in the public WAMP directory, you don't need php artisan serve at all (I for one have never used it and I've developed on both Windows and Linux).

But if you've got it all set up correctly, in the Apache config you need to set a ServerAlias for the domain name:

<VirtualHost *:80>
    ServerName MyProject
    ServerAlias yourdomain.ext www.yourdomain.ext
    DocumentRoot c:/wamp/www/MyProject/public
    <Directory  "c:/wamp/www/MyProject/public/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
    </Directory>
</VirtualHost>

Then, your project is available to your agents via http://yourdomain.ext/anyRoute

1 like
marcor's avatar

@Thyrosis you hit the point which I couldn't write in words :D.

That is exactly my problem.

I have a running server named Myserver and on it I have a successfull wamp installation with non-laravel working projects. from my agent's pc, I can visit my projects like this: "http://Myserver/projectName/index.php" for example

Now I started working with Laravel and I want to deploy a project called LarProject.

I put the folder LarProject in the www directory on Myserver. Added the following to the httpd-vhosts.conf file:

<VirtualHost *:80>
    ServerName LarProject
    ServerAlias Myserver.sub www.Myserver.sub 
    DocumentRoot c:/wamp/www/LarProject/public
    <Directory  "c:/wamp/www/LarProject/public/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
    </Directory>
</VirtualHost>​

But from my agent's pc when i go to: "http://Myserver.sub/anyRoute" i get "NotFoundHttpException"

Am I missing something here?

On my local machine, i did the same concept and it works

marcor's avatar

hi guys, after running through the entire architecture searching for the problem since the configuration i used should be working. I stumbled upon a strange thing:

in the httpd-vhost.conf file: if I remove the following:

<VirtualHost localhost>
    ServerName localhost
    DocumentRoot c:/wamp/www
    <Directory  "c:/wamp/www/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        
    </Directory>
</VirtualHost>

and leave only

<VirtualHost *:80>
    ServerName LarProject
    ServerAlias Myserver.sub www.Myserver.sub 
    DocumentRoot c:/wamp/www/LarProject/public
    <Directory  "c:/wamp/www/LarProject/public/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
    </Directory>
</VirtualHost>​

the Laravel project works but all my other projects won't work.

Any idea on this?

avril_hansen's avatar

The ServerName is supposed to be "something.tld" and alias could be "www.something.tld". If you say laraproject, it should give you some interresting resolution trouble.

Also, which version of apache is it? In Apache 2.4 you should add: Require all granted (a gotcha for those who are used to install apache https://httpd.apache.org/docs/2.4/upgrading.html)

The one on the top looks wrong to me. It simply looks like a funny specification and it should at least have a specified port. Instead of removing it, change the virtualhost to *:80 (so that servername is ServerName localhost:80 responding to localhost on port 80). - Im guessing that will fix the other sites. They are both supposed to be there :)

marcor's avatar

Hi @avril_hansen thank you for the reply,

the one on top ships with wamp by default which makes it legitimate to work with. My problem is clearly related to wamp not being able to resolve my virtual hosts using the method described above, thus taking the first virtual host by default.

I also added Require all granted but it didn't solve my problem.

One thing does work is when i put the serverAlias as my full domain which is MyServer.company.com.lb but any other alias won't work.

Thanks mate

Thyrosis's avatar

@marcor , I just installed WAMP on my own Windows (10) machine and got it set up with one of my Laravel projects.

Are you using WAMP 3? In that case you can use the tutorial on this page to set up your extra virtual host: http://forum.wampserver.com/read.php?2,136483,136818#msg-136818 . Don't forget to follow all the steps, like clearing the DNS cache and clicking the VirtualHosts sub-menu.

Following that, I altered the vhost-file a little:

<VirtualHost *:80>
    ServerName tempdev.space
    #DocumentRoot "c:/wamp64/www/tempdev"
    DocumentRoot "c:/wamp64/www/tempdev/public_html"
    <Directory  "c:/wamp64/www/tempdev/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

This change ensures that I can visit http://tempdev.space to visit my project, instead of http://tempdev.space/public_html (I'm using public_html instead of the default public folder, because my hosting server is set up like that).

Now, it works flawlessly and I don't have any issues with routing.

MaverickChan's avatar

try this:

//your laravel project

<VirtualHost *:80>
    ServerName LarProject
    ServerAlias Myserver.sub www.Myserver.sub 
    DocumentRoot c:/wamp/www/LarProject/public
    <Directory  "c:/wamp/www/LarProject/public/">
        //you really don't need other settings
        AllowOverride All
    </Directory>
</VirtualHost>

//other project
<VirtualHost *:80>
    ServerName other
    ServerAlias otheralias
    DocumentRoot c:/wamp/www/other/public
    <Directory  "c:/wamp/www/other/public/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
    </Directory>
</VirtualHost>

//repeat above

//....

marcor's avatar

Hi @Thyrosis, Thank you for your reply I did stumble upon that tutorial, i followed it even that I knew the steps and it wasn't the first time I work with it (i've done it with non-laravel projects). Yes I use wamp 3.0.6

btw, using you configuration will work on my server itself if I visit on the browser in Myserver the following url: http://LarProject/AnyRoute. But the problem is when trying to access it via the agent's pc.

Hi @MaverickChan

Thank u for your reply. Using what you gave me didn't solve my problem but enlighted me to write the following: I will try to explain my problem as thoroughly as possible.

I have multiple agents and one server. My server is called MyServer.

on MyServer, I have installed wamp (root directory c:\wamp\www) and I have been working with it since forever.

My agents currently access my server via: http://Myserver/projectName

I recently started to use Laravel and want to deploy my first project which is called LarProject.

My v-hosts file:

# Virtual Hosts
#the below virtual host will be used when no other virtual host is found (default)
<VirtualHost *:80>
     DocumentRoot "c:/wamp/www"
     <Directory  "c:/wamp/www">
        AllowOverride All
     </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName LarProject
    DocumentRoot c:/wamp/www/LarProject/public
    <Directory  "c:/wamp/www/LarProject/public/">
        AllowOverride All
    Require All Granted
    </Directory>
</VirtualHost>

My hosts file contain:

127.0.0.1   localhost
::1 localhost
127.0.0.1   LarProject
::1 LarProject

My routes file for project LarProject contains:

Route::get('/', 'MyController@loadPage');
Route::get('firstPage', 'MyController@firstPage');
Route::get('secondPage', 'MyController@secondPage');

on my agents pc, when I run: http://Myserver/LarProject/public/ which is initially not what i intended as a url, I reach the loadPage and the page is displayed. but when i try http://Myserver/LarProject/public/firstPage or any other route, I get an httpNotFoundException.

If I even change the first route to Route::get('/loadPage', 'MyController@loadPage') and try to access it via http://MyServer/LarProject/public/loadPage I get an httpNotFoundException

Please note that if I add a ServerAlias i.e. MyServer.loader and I access it from my agent's pc via http://MyServer.sub/LarProject/public/ , I get

The requested URL can not be retrieved 
Unable to connect to remote webserver.

Now I know that accessing the project via the public folder is not actually using the v-hosts file, but when I access it via the v-hosts configuration i.e. http://MyServer/larProject/AnyRoute, I get

The requested URL /larProject was not found on this server.

I hope my detailed explanation can shed the light on a solution.

Thanks in advance

MaverickChan's avatar
  1. in your v-host file delete the last / of directory

  2. hosts file , delete ::1 of Larproject

  3. to visit your Larproject , type http://larproject/ , due to your setting.

marcor's avatar

@MaverickChan thanks for the reply i did what you said but he last step only will work on the server and not from any agent's pc! for example, if you use: http://larproject/AnyRoute on the server's browser it will work. but how would you access this url from the agent's pc?

While trying this, I changed the port of the virtual host to 81: <VirtualHost *:81>

it worked!!! on my agent's pc i could visit: http://Myserver:81/AnyRoute

but this doesn't help me much since using this, i'd need to change the port for each virtual host i use; in addition, this way, the project ain't being referenced here e.g. http://MyServer/LarProject/AnyRoute

Please or to participate in this conversation.