*(Click [here to try Gandi Simple Hosting](<https://gandi.link/f/4a9c1f95>) with 6 months free hosting)*

I host a lot of my projects on Gandi.net hosting, and when I started using the [**Laravel**](<https://laravel.com>) PHP web framework, it wasn’t obvious at first how to run a Laravel project on Gandi Simple Hosting. So let me describe the way I do it.

[![](<https://mk.forret.com/wp-content/uploads/2020/03/LaravelDefault.png>)](</wp-content/uploads/2020/03/LaravelDefault.png>)

### 1\. “Deploy with git” websites

- create a new hosted site on Gandi Simple Hosting (e.g. `app.example.com`)
- create a new Laravel project on your development machine via terminal  
  `laravel new app.example.com`
- wait until the process is done and move into the new directory  
  `cd app.example.com`
- create a symbolic link for `htdocs` (what Gandi uses for the website files) to `public` (what Laravel uses for website files)  
  `ln -s public htdocs`
- initialize your git repo  
  `git init`
- now set your remote repo to the Gandi URL  
  `git remote add gandi git+ssh://<yourid>@git.yyy.net/app.example.com.git`  
  *(the exact URL is shown on your Gandi dashboard)*

[![](<https://mk.forret.com/wp-content/uploads/2020/03/gandi_site.png>)](</wp-content/uploads/2020/03/gandi_site.png>)

- add your code to git and do your first commit

```
git add .
git commit -a -m "first commit"
```

- now push your code to Gandi  
  `git push gandi master`
- before you deploy for the first time: rename the old `htdocs` to `htdocs_old`, via regular SSH (first start the ‘emergency console’) or via the [Gandi CLI](<https://cli.gandi.net/>) (my preferred method)

```
gandi paas console [yourserver]
cd vhosts/app.example.com/
mv htdocs htdocs_old
```

- deploy your Laravel project for the first time  
  `ssh <yourid>@git.yyy.net deploy app.example.com.git`  
  *(you will see that there is an automatic `composer install` phase)*
- in the CLI you still have open, create the .env file and initialize it  
  `cp .env.example .env<br>php artisan key:generate`
- edit the .env file to use the correct database, set the app to ‘`prod`’ etc
- open *app.example.com* in your browser
- Tada!

### 2\. “Deploy with git” bash script

> UPDATE: I upgraded this simple deploy script into a better **gandi\_deploy** script: [Easy site deployment on Gandi with git and gdeploy](</2020/04/06/easy-site-deployment-on-gandi/>)

To make re-deploying the project easier, I use a simple `redeploy.sh` bash script:

```
#!/bin/sh
   git commit -a \
&& git push gandi master \
&& ssh &lt;yourid&gt;@git.sd6.gpaas.net deploy app.example.com.git
```

Be sure to add your public key `id_rsa.pub` to the Gandi SSH key list, so you won’t have to give a password for the `git push` and `ssh deploy` step.

### 3\. “Update via sFTP” websites

- create new hosted site on Gandi Simple Hosting (e.g. `app.example.com`)
- create a new Laravel project on your development machine via terminal  
  `laravel new app.example.com`
- wait until the process is done and move into the new directory  
  `cd app.example.com`
- create a symbolic link for `htdocs` (what Gandi uses for the website files) to `public` (what Laravel uses for website files)  
  `ln -s public htdocs`
- initialize your git repo (not required here, but always a good idea)  
  `git init`
- use your sFTP client (e.g. Filezilla) to login to your Gandi server `sftp.yyy.net` and browse to the folder `vhosts/app.example.com/`
- before you deploy for the first time: rename the old `htdocs` to `htdocs_old` via the FTP client (FileZilla)
- now upload the whole website to Gandi. You should see that the root folder contains the `htdocs_old`, the `public` folder and the `htdocs` symbolic link to it.
- in the CLI you still have open, create the .env file and initialize it  
  `cp .env.example .env`  
  `php artisan key:generate`
- edit the .env file to use the correct database, set the app to ‘`prod`’ etc
- open app.example.com in your browser

> Also check out the [gandi-deploy / gdeploy.sh](</2020/04/06/easy-site-deployment-on-gandi/>) script for even easier deployment and administration
