Configuring Shared Folders

Steps to Configuring Shared Folders in Laravel Homestead:

  1. Run init.bat command from the Homestead directory to create the Homestead.yaml configuration file.

init.bat
Run init.bat command from the Homestead directory.
  1. Run code . command from the Homestead directory to open the repository in VS Code.

C:\vm\Homestead>code .
  1. Select Homestead.yaml file to display configuration.

  1. Update the folders: configuration with the below configuration:

```
folders:
    - map: /code
      to: /home/vagrant/code
      type: "nfs"
```
  1. Create a directory/folder mapping to share your Laravel project/code between your host and Homestead guest machine. In this example, I mapped the C:\code folder to the /home/vagrant/code folder in the Homestead virtual machine.

  1. Update the sites: configuration, by adding your project name.


sites:
    - map: acware.test
      to: /home/vagrant/code/{projectname}/public 
      

In this example, we named the project mylaravelapp which will be discussed in detail in Creating a Laravel project in Homestead.

  1. Your Homestead.yaml configuration will look like this:

---
ip: "192.168.56.56"
memory: 2048
cpus: 2
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: /code
      to: /home/vagrant/code
      type: "nfs"

sites:
    - map: acware.test
      to: /home/vagrant/code/mylaravelapp/public 
    

databases:
    - acw

features:
    - mysql: true
    - mariadb: false
    - postgresql: false
    - ohmyzsh: false
    - webdriver: false

services:
    - enabled:
          - "mysql"
#    - disabled:
#        - "postgresql@11-main"

#ports:
#    - send: 33060 # MySQL/MariaDB
#      to: 3306
#    - send: 4040
#      to: 4040
#    - send: 54320 # PostgreSQL
#      to: 5432
#    - send: 8025 # Mailhog
#      to: 8025
#    - send: 9600
#      to: 9600
#    - send: 27017
#      to: 27017
  1. Save the changes to the Homestead.yaml file and exit.

  2. You need to install the vagrant-winnfsd plugin for type: "nfs" configuration by running the following command in your terminal:

vagrant plugin install vagrant-winnfsd
  1. This required restarting the computer after the installation.

That's it! You have successfully configured shared folders in Laravel Homestead on a Windows machine.

In the next topic, we will generate SSH Keys. SSH keys are a pair of cryptographic keys (a public key and a private key) that can be used to authenticate with remote servers or services, without the need for a password.

Last updated