Laravel Homestead Add Packages After Provisioning

Laravel Homestead offers much of what you’ll need to develop your applications out of the box. However, you may end up with a project that requires software beyond what is installed by default. For shared/universal Homestead, be aware that anything extra you install or configure may affect your projects. Personally, I prefer to use a Per Project Homestead installation. To my point, you don’t have to vagrant up and the ssh into your Homestead box to add packages. You can add an after.sh file to your project root before you provision and the commands you specify will be run after the box is initially provisioned (or re-provisioned after destroying it.

For example, I have a project that deals with audio files for which I need sox and lame. My after.sh looks like this:

#!/bin/bash
sudo apt-get -y install sox
sudo apt-get -y install lame

You can run whatever you like from here. For example, maybe you don’t want Postrges. Go ahead and remove it:

#!/bin/bash
sudo apt-get -y install sox
sudo apt-get -y install lame
sudo apt-get -y --purge remove postgresql\*

That’s it. Since the file isn’t created by default, you might not have realized you can add it without having looked at the Vagrantfile.

Leave a Comment

Your email address will not be published. Required fields are marked *