Deploying Laravel is thankfully pretty straightforward. People have been deploying PHP apps for nearly 30 years so it’s a solved problem. There are plenty of options and after using plenty of them, I would highly recommend using one of the two first-party Laravel hosting options.
One difference between hosting PHP vs JS is you don’t need a running application process - i.e. you don’t need to
npm run start
and listen on port 3000. Your web server will take care of taking an incoming request, running your Laravel App for the duration of the request and sending back a response.(well actually…)
Here are the most common ways to deploy Laravel apps:
- Laravel Forge - First-party, configures a server for you and manages deployments & updates.
- Laravel Vapor - First party, full serverless infrastructure management. Bring your AWS account and Vapor manages the infra, plumbing & deployments.
- PaaS - e.g. Railway, Render, AWS Elastic Beanstalk Connect to GitHub or run a
deploy
command and let them handle the rest.
- Fly.io - I’m not smart enough to understand but it does some magic with Docker so you don’t have to and lets you do multi-region deployments quite easily.
- Self-Hosted VPS - e.g. DigitalOcean, Hertzner, AWS EC2 Configure PHP, a web server, a database, etc yourself and figure out deploying yourself. #BringBackFTP
Which should you choose?
If you are just testing things out…
I would use a PaaS. If there is one you’re already familiar with and they support PHP, they will likely have a Laravel template. Railway is a good option. You can deploy with a couple of commands and hook up to GitHub to deploy when you push to
main
. You’ll likely get something up and running for free.If you want a great experience when starting out…
I would use Forge. Forge costs $12/mo to manage your servers. You’ll need to bring your own hosting account. If you already use one of their supported server providers, just hook up your account. Otherwise I would create a DigitalOcean account and use Forge to create a $5/mo VPS for it to manage.
You should have an exceptionally smooth experience and can deploy via GitHub or CLI.
If you’re scaling…
I would use Vapor. Vapor manages all of the infrastructure to scale a growing Laravel app for you. It’s rock solid, is great to use and is constantly having new features added. Vapor manages AWS resources for you so you’ll need to bring your own AWS account and hook it up (and pay the bill).
Option #1: Laravel Forge
Laravel Forge was launched in 2014 by Taylor Otwell, the creator of Laravel. Forge replaced the need to manually configure web servers with a tool that would provision & configure servers for you, and manage their deployment & maintenance.
It is probably the smoothest experience and perfect for generating income that doesn’t need to scale to infinity. I use Laravel Forge for almost all of my projects.
Their cheapest plan is $12/mo and with a $5/mo DigitalOcean droplet you’ll be looking at $17/mo which might be more than you want to spend for a side project that will get a handful of users.
See the story of how Laravel Forge came to be from the Laravel Documentary:
Option #2: Laravel Vapor
Laravel Vapor hooks up to your AWS account and manages the infrastructure you need for a rock-solid serverless Laravel deployment.
I have been part of a team scaling a Laravel application to 10s of millions of requests per day. There was plenty of plumbing work to be done between different services, strange issues, and generally more for you to manage.
For my new startup I have gone with Laravel Vapor from the outset. It’s more than we need at the moment but I know I can trust that it works now and will continue working with no extra effort for the lifetime of the business.
Jack Ellis of Fathom Analytics has a fantastic course called Serverless Laravel which can explain it much better than I ever can.
Option #3: PaaS
There are plenty of services in the category of “hook up a GitHub repo or run a CLI command and we’ll handle the rest” e.g. Railway, Render, AWS Elastic Beanstalk. I have used Elastic Beanstalk for a Laravel Application and Railway for non-Laravel projects.
Lots of these services have free tiers which might be a good fit for a hobby project.
Option #4: Fly.io
I know the least about Fly.io. I have deployed a hobby site to it and was a happy beneficiary of their generous free plan.
From what I understand it’s like AWS Lambda but instead of a function that runs for a few seconds, it uses the same magic to create a long-running server.
I have not personally deployed a Laravel application to Fly but they hired Chris Fidao, the unofficial CEO of Laravel+Servers, and he has a whole series on Fly’s blog called Laravel Bytes worth checking out.
Option #5: Self-Hosted VPS
If setting up a Ubuntu server, artisanally crafting your nginx/apache config,
sudo apt-get
ing all of your favourite tools, etc is your jam then go ahead.Or pay Laravel $12/mo to have Forge do it for you and spend all that extra time you’d save scrolling through the latest architecture war on Twitter instead.
Conclusion
Hopefully that’s a useful insight into ways Laravel applications are hosted. I personally am using both Forge & Vapor for different projects and love them both. As always, choose the right tool for the job and good luck!