Search code examples
laravelvagranthomestead

How to run a post-vagrant-up script with Laravel Homestead


I am running a Laravel application which uses Homestead for its vagrant box setup. I see that there it looks for a after.sh file where you can put custom scripts to run during provisioning, but I don't see any place where I can have it run something on EVERY vagrant up. What I would like it to run every time the box loads is pm2 start [process-name.yaml].

How can I achieve this?


Solution

  • you can add the following line in your Vagrantfile

    config.vm.provision "shell", inline: "pm2 start [process-name.yaml]", run: "always"
    

    you can add privileged: true if you want this to be be run with sudo privilegies