Laravel Provisioning and Deployment – What are your options?

When you work with Laravel and need to take care of the actual launch of the web application there tend to be two things you need to take care of. You need to set up the server or provision it as they call it. Two, you need to set up a deployment system to update it. When you roam the web for options you will find out there aren’t really many out of the box solutions.

Local Development

Let me briefly touch upon local development. Homestead or Laravel Valet are awesome for local development. And these options are totally for free. There is even Laradock if you prefer to work with Docker containers. But from local development you will need to go to staging and production to test things online and ultimately push to production. So what are the options out there?

Provisioning

There are as always multiple options to set up your own staging or production server that plays nice with Laravel PHP. Here are the main ones.

Laravel Forge

To have a server setup online for staging and or production Laravel Forge is your go to person. It is a provisioning and basic deployment GUI set up by the folks behind Laravel itself and is really easy to work with. It will cost you though. It comes at a minimum $19 dollars per month. You do get unlimited servers, websites and deployments though. The only downside is that deployment will not be without downtime. For that you will need Envoyer . More on that later.

Laravel Forge

Cloudways Managed Laravel Cloud Hosting

Another option is Cloudways Managed Laravel Hosting. They have a relatively new managed hosting package for Laravel. And it sets you up nicely and on top offers all their goodies like basic githooks, server or app cloning and so on. I was and still am interested in this set up. The server setup is beautiful with  caching, Nginx for static files, Apache for dynamic files, PHP 7 and so on. Downside here is no zero downtime deployment available nor full root access it being managed hosting.

Cloudways Laravel Hosting

DIY Server Stack

A third option is a DIY option. You set up the entire server yourself using the command line, Bash scripts or Ansible Playbooks. I have not found any decent repos that help you set up a server let alone one that mirrors Homestead. But you could do a first setup and create Bash scripts based on it. You could also clone a setup you use a base for future Laravel setups. And you can of course always get started with a LEMP VPS with Digital Ocean or another Cloud Provider.

Stedding

Stedding is a set of Ansible playbooks for a Laravel LEMP Stack I have been working on for the last two to three weeks. The project Stedding is ongoing. If you do have time and interest, please take it for a spin and send in your pull requests. I could sure use some help and or feedback. Mind you, it is not done as of yet. Still a work in progress. It does however set up a:

  • LEMP stack with
  • NGinx
  • MariaDB
  • PHP 7.1
  • Git
  • Memcached
  • admin and web users
  • Composer
  • Node
  • Certbot Let’s Encrypt SSL
  • Laravel Webroot

I am also going to add Deployer for zero downtime deployment, but for now I have not added it to the server.yml as a role to be included. There are other issues I have to work on first like

  • Composer inside web user path,
  • Cerbot Nginx Plugin full SSL certificate automation – only partly done now,
  • Nginx config tweaks to have browser caching and compression taken care of

and what not. But hey, I am getting there and with your help things will go even quicker 😉 .

Deployment

For deployment Laravel has setup a zero downtime solution called Envoyer. And it can work in tandem with Forge and is also a really nifty tool. Again, you would need to pay for this and perhaps on top of your Forge setups. It starts at $10 USD a month. For this you can work on ten projects. So if you work with three Git branches I assume that would be 3 projects already.

Laravel Envoyer

So what are the alternatives when you do not want to cough up $10 or more a month? Well you could use Deployer or Deploybot. The former is 100% for free and works with Laravel and is recommended by us. The Deploybot also looks good but is commercial and is at least $15 a month. So Deploybot is not much of a choice here as Envoyer will be cheaper.

Deployer

The other alternative is of course setting up your own Githooks and setting up symlinking the latest deploy to your production webroot. But to me as Deployer is a great a free tool and helps out with all this I would not really roll my own. Just like I am not writing all Ansible Playbooks myself. No need to reinvent the wheel no is there?

Epilogue

Well, there you have it, the lowdown on Laravel PHP Server provisioning and deployment. If you have a great alternatives or know of great repositories that we could use to automate the setting up of staging and or production servers please let us know!

Tagged in : Tagged in : , , ,
Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.