deployment

All my posts about deployment.

Join 9,500+ smart developers

Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.

No spam. Unsubscribe anytime. You can also follow me on X.

Using the 1-click-installer to set up Mailcoach in no time original

by Freek Van der Herten – 7 minute read

A couple of weeks ago, we released Mailcoach: an affordable, self-hosted solution to send out newsletters. Installing it into an existing Laravel application is quite easy if you have experience with Laravel.

We wanted to make getting started with Mailcoach easier for those without experience with Laravel or PHP. Using our a 1-click-installer on the Digital Ocean marketplace you can set up an entire Mailcoach installation in a couple of minutes.

In this blogpost I'd like to show you how you can use the installer and how we built it.

Read more

Serverless Laravel

mnapoli.fr

A few weeks ago Matthieu Napoli released Bref, a tool to get any PHP project up and running in a serverless environment. Matthieu has managed to get working serverless too.

Serverless basically means “Running apps without worrying about servers”. The main difference with a traditional hosting is that you do not maintain the servers and reserve their capacity. They are scaled up or down automatically and you pay only for what you use. ... Today let’s try to deploy a Laravel application on AWS lambda using Bref.

Read more [mnapoli.fr]

Shipping Docker, a video tutorial series on Docker

Chris Fidao, the hero behind serversforhackers.com, and Deploy PHP!, created a new video course called Shipping Docker. It's in early access right now and it covers everything from the basics to advanced topics like building a multi-server production environment.

I'm only a couple of videos deep in the course, and like expected, I'm liking a lot of what I'm seeing.

This is a comprehensive course in the many uses of Docker. From playing to developing, testing to deploying, we'll cover it all in a way that is easy to understand.

https://shippingdocker.com/

(In case you were wondering, I'm not being paid for posting this)

Read more

A checklist for all projects that are going live original

by Freek Van der Herten – 2 minute read

Apart from our open source work, we do client work at Spatie as well. Over the years we've learned that one of the most critical moments of a project is when it is going live. No matter how you confident you are about the correctness of the code base there are so many big and little things that…

Read more

Upgrading PHP 5.6 to 7.0 on a Forge provisioned server

If you've read some posts before on this blog, then you'll probably know that I'm a big fan of Forge. The service makes it very easy to set up and administer servers. At my company we've been using it since it launched.

We currently have 80 provisioned servers. Most of them are small droplets. We have a policy of running every site on it's own droplet. This approach has many benefits, but that's maybe something for a future post.

The bulk of our servers are on PHP 5.6. That's not too bad, but once you have some sites on PHP 7, the sites running on those servers feel a bit slow. It's amazing how fast you get used to the speed that PHP 7 offers. That's why I experimented a bit with upgrading the PHP version on a Forge provisioned server. My gut feeling was that upgrading the PHP version is less work that setting up a new server and moving a site to it.

To not mess up a live site I created a snapshot and used that to set up a server to toy around with. With a little bit of research I came up with these instructions to upgrade the PHP version.

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

sudo apt-get install php7.0

sudo apt-get install php7.0-fpm

Depending on your project you will need less or more php extensions, but these were the ones relevant for my site:

sudo apt-get install php7.0-gd

sudo apt-get install php7.0-mysql

sudo apt-get install php-memcached

sudo apt-get install php7.0-mcrypt

sudo apt-get install php-curl

sudo apt-get install php-imagick

Next, in the nginx configuration of the site I replaced unix:/var/run/php5-fpm.sock with unix:/var/run/php/php7.0-fpm.sock

The final adjustment I made was to make sure nginx would spawn the php processes under the forge. This will make sure that a php process can write to sites previously created by Forge:

// in the file /etc/php/7.0/fpm/pool.d/www.conf
...
user = forge
group = forge
...

After that I rebooted the server (maybe just restarting nginx is enough) and enjoyed browsing a site that was four times as fast. ?

If you decide to try this out for your server, be aware that what works for me doesn't necessarily work for you. Every site is a bit different. But I'm sure the instructions from this post will get you pretty far. Happy upgrading!

EDIT: Meanwhile DigitalOcean also published a guide on how to upgrade to PHP 7.

Read more

Zero downtime deployments with Envoy original

by Freek Van der Herten – 4 minute read

Envoy is Laravel's official task runner. Using a Blade style syntax tasks can be defined that can be run both locally and remotely. At Spatie, we've been using Envoy for quite some time to deploy code on production servers. Summarized our trusty Envoy script did the following things: bringing the…

Read more