Skip to content

Instantly share code, notes, and snippets.

@henrytriplette
Last active June 30, 2020 09:32
Show Gist options
  • Save henrytriplette/529e8581856b4a11546baa040d36bc37 to your computer and use it in GitHub Desktop.
Save henrytriplette/529e8581856b4a11546baa040d36bc37 to your computer and use it in GitHub Desktop.
Laravel Homestead - Install on a per project base on Win10

Install Laravel Homestead on Win10

  • Use Git Bash as your command prompt

  • Official Instructions [LINK]

  • Install Oracle Virtualbox [LINK]

  • Install Vagrant [LINK]

  • Add Homestead into Vagrant:

vagrant box add laravel/homestead

Install Homestead per project on Win10

  • Create new project with composer
composer create-project --prefer-dist laravel/laravel rhind-laravelTest
  • Enter the folder
cd rhind-laravelTest
  • Add homestead as a dev dep.
composer require laravel/homestead --dev
  • Check homestead installation
vendor/bin/homestead
  • Build config file
vendor/bin/homestead make
  • Check ssh keys
ls ~/.ssh/
- make new ssh key if empty
ssh-keygen -t rsa -C "[email protected]"
  • Check if cmd is run as admin, otherwise Windows won't be able to create the .ssh files with the correct user permissions
net session
  • Configure the Homestead.yaml file as follows:
ip: 192.168.10.10
memory: 2048
cpus: 2
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
    - ~/.ssh/id_rsa
folders:
    -
        map: 'd:/Sites/rhind-laravelTest'
        to: /home/vagrant/code
sites:
    -
        map: laraveltest.test
        to: /home/vagrant/code/public
	type: "apache"
databases:
    - laraveltest
features:
    - mariadb: false
    - ohmyzsh: false
    - webdriver: false
name: rhind-laraveltest
hostname: rhind-laraveltest
  • Add ssh fix to Vagrantfile inside the Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| section:
config.vm.boot_timeout = 6000
config.ssh.insert_key = false
config.ssh.private_key_path = ["~/.ssh/id_rsa", "~/.vagrant.d/insecure_private_key"]
config.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "~/.ssh/authorized_keys"
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
  • Edit the Windows host file and add the Laravel host entry
## Vagrant ##
192.168.10.10  laraveltest.test
  • Launch Vagrant
vagrant up
  • Login into Vagrant
vagrant ssh
  • Check if files are moved into the vm
ls code/
  • Quit the shell
exit

Issues with nginx

  • Inside /etc/nginx/sites-enabled/[WEBSITETENAME].test: do:
sudo nano /etc/nginx/sites-enabled/[WEBSITETENAME].test

and edit:

fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; => fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
  • Also disable xdebug via:
sudo nano /etc/php/7.4/mods-available/xdebug.ini
  • Reboot nginx service and fpm with:
sudo service nginx restart
sudo service php7.4-fpm restart

Issues with apache

  • Error 503: List the error logs and open the correc one
ls /var/log/apache2/
tail -f /var/log/apache2/segnoprogetto-area-sciencepark.test-error.log

If error FCGI: attempt to connect to Unix domain socket /var/run/php/php7.4-fpm.sock (*) failed run:

sudo service php7.4-fpm start

Vagrant Useful commands

  • List all vagrant installed instances
vagrant global-status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment