Skip to content

Instantly share code, notes, and snippets.

@rseon
Created October 30, 2019 10:51
Show Gist options
  • Save rseon/5436cb61823e34857127c54b0d4f14aa to your computer and use it in GitHub Desktop.
Save rseon/5436cb61823e34857127c54b0d4f14aa to your computer and use it in GitHub Desktop.
Laravel + Homestead

Laravel + Homestead (Windows 10)

Nom du projet : my_project URL : my.project.dv

Laravel

Dans le répertoire qui accueille nos fichiers de site :

  • Laravel installer (optionnel) : composer global require laravel/installer
  • cd D:\www
  • laravel new my_project
    • (ou sans l'installer Laravel : composer create-project --prefer-dist laravel/laravel my_project)
  • cd my_project
  • npm install

Homestead

Installation par projet :

  • Install Virtualbox
  • Install Vagrant
  • Install Homestead box : vagrant box add laravel/homestead
  • composer require laravel/homestead --dev
  • vendor\\bin\\homestead make

Configurer le fichier Homestead.yaml :

ip: 192.168.10.10
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
    - ~/.ssh/id_rsa
folders:
    -
        map: 'D:\www\my_project'
        to: /home/vagrant/my_project
sites:
    -
        map: my.project.dv
        to: /home/vagrant/my_project/public
databases:
    - my_project
features:
    -
        mariadb: false
    -
        ohmyzsh: false
    -
        webdriver: false
name: my-project
hostname: my-project
backup: true

Ajouter l'IP dans le fichier C:\Windows\System32\drivers\etc\hosts : 192.168.10.10 my.project.dv

Vagrant

  • Lancer la VM : vagrant up
  • L'URL http://my.project.dv est accessible
  • Status des VM : vagrant global-status
  • Connexion SSH : vagrant ssh
  • Eteindre la VM : vagrant halt
  • Détruire la VM : vagrant destroy

MySQL

  • Host : 127.0.0.1
  • Port : 33060
  • User : homestead
  • Pass : secret

Backup

En cas de destruction de la machine, un backup de la base de donnée est disponible dans le répertoire mysql_backup. Pour le restaurer :

  • Connexion SSH : vagrant ssh
  • Connexion Mysql : mysql
  • Utilisation de la database : use my_project
  • Import du fichier (attention au nom du fichier) : source /home/vagrant/my_project/mysql_backup/my_project-201910301141.sql
  • Sortie de Mysql : exit
  • Sortie du SSH : exit

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment