Using Gitlab to Deploy Laravel App to Shared Hosting via SSH

I developed some small sites for organizing events with my friends or supporting some blogs all hosted on a shared hoster service in Switzerland (if you are considering using cyon too, please use my referral link at the end of this blog post).

Sometimes I have to quickly fix or change things and then annoy me that it is so tedious to connect via ssh and do everything right when updating the latest version of the app. In the case of Laravel I have to clear the caches and install newest composer packages.

As I use Gitlab for some other projects together with Laravel Forge (, Also a great service to use with your own VPS), I searched a way to automate this in a more restricted shared hosting environment.

Here is how I did it.

Setup Project

Just setup the Site as you as you would normally do. Then checkout your project via git from gitlab. In this example it’s done with the following:

Of course you have to setup the DNS but I’ll not cover that here.

Configure CI/CD

Just study the following Guide to to the whole thing together with Laravel Envoy (what I haven’t used yet).

This guide works without Laravel’s Envoy.

Add cat ~/.ssh/ to deploy keys of your repository in gitlab.

Environmen Variables set (don’t want them to be in my configs!):


Use this .gitlab-ci.yml config: (run in docker image mightycode/docker-laravel-dusk:latest or any other php testing docker container image) (Run via ssh on server to simplify process)


Configure Runner for better Performance

Don’t forget to configure cache correctly on the runner (Safes a lot of time!)
sudo vim /etc/gitlab-runner/config.toml

My Actual runner config

sudo gitlab-ci-multi-runner restart

Support this Post by using my referral link:

Leave a Reply

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