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

DoeJohn's avatar

How to Deploy Laravel project on VPS and How to manage changes?

Hi,

I'm using Windows with XAMPP when developing web applications (with Laravel). Also, I use Git for version control. When I finish a project, I'll have to deploy it on VPS (LAMP). How do you do it? For now, two ideas come to my mind:

  1. SFTP - For example, I would use MobaXterm's Graphical SFTP browser, I would just copy my project (files)... and then I would import MySQL database (or run migrations).

  2. Git/GitHub - on my VPS I would install Git and then I would:

  • create a remote repository on GitHub (should it be private?)
  • git push (from localhost to GitHub)
  • and then, on VPS, I would do git clone (from GitHub to VPS)
  • finally, I just need to import MySQL database (or run migrations).

Do you work in this way, or there is a better solution? I suppose that the second way (Git/GitHub) is better than the first (SFTP) because if I have to add some new features or fix bugs - all I will have to do on the server is: git pull (from GitHub).

EDIT:

Now I see that there are services such as envoyer.io and forge, but they are not free. So, what are the disadvantages of the second way (2. Git/GitHub) that I described in my question, which is free?

0 likes
6 replies
zachleigh's avatar

Envoyer and Forge also use git, they just make it super easy. The only disadvantage of using git without one of these services is that it can be time consuming and difficult to have zero downtime (which Envoyer can achieve). You have to manually set up your server, maintain it yourself, ssh into it if you want to pull in a new version etc. Its totally doable (I do it for several sites) but it can take a lot of time, especially if you've never done it before.

DoeJohn's avatar

@zachleigh Speaking about the free way, I just discovered that if you need a private repository and you don't want to pay for it on GitHub - there is GitLab Community edition (host it on your own server) OR GitLab.com (No installation required). I've never used GitLab, but for now it seems like the best free solution (if you need a private repository). If you don't need a private repository, GitHub is fine.

By 'time consuming' & 'zero downtime' what do you mean? Let's say that I added some new feature to my web app, I pushed it on remote repository on GitHub (or GitLab) - and then all I need to do on VPS is: git pull, right? This looks very simple and quick.

kjdion84's avatar

There is also deploybot, which allows you to manually or automatically deploy your repository commits via FTP/SFTP/SSH/etc.

https://deploybot.com/

That's what I use ( although I'm about to write my own app that does this with Laravel :) ).

zachleigh's avatar

It can be time consuming because you have to maintain the server yourself. If you know a bit about Linux, you should be okay, but dealing with updates, dependencies, etc can take a bit of time, especially if something goes wrong. If your server goes down for an unexpected, unknown reason it can really suck.

I dont know how Envoyer achieves zero downtime, but doing it on your own is quite a lot of effort. Generally, if you update your app and have to install new dependencies, or if your update your server, your site might go down for a minute or two. If its a small site, its not such a big deal, but if you have thousands of daily visitors who depend on your site, this can be a big inconvenience.

But yeah, it generally isnt so bad. Just be sure to never update code on the server outside of .env and anything else in your gitignore file.

MikeHopley's avatar

I dont know how Envoyer achieves zero downtime

I believe it deploys to a version-stamped folder. Then it waits until the composer install is finished, before creating a symlink to the new folder.

Here is a fuller explanation.

This isn't 100% perfect. You also need to run artisan migrate at some point, and you only have "one copy" of the database. You could argue that it's safest to wrap this in a brief downtime:

// Begin the deployment here, wait until composer install finishes, then:
php artisan down
php artisan migrate

// Add the symlink here, then:
php artisan up
1 like

Please or to participate in this conversation.