Setting Up
Setting Up Your Computer
Homestead
Turning on Homestead
cd ~/Homestead
vagrant up
Configuring Homestead
cd ~/.homestead
gedit Homestead.yaml
Configuring Shared Folders
Read more about Homestead here
- Scroll down to the
folders
property in yourHomestead.yaml
file. - For example:
The main folder where you put your projects into is a folder namedProjects
.
- The folder is located at
~/Documents/Projects
on your computer. - You want to set up a folder named
Projects
in root of the Vagrant box to contain your project folders.
This is how you would configure your Vagrant box inside yourHomestead.yaml
file:
- The folder is located at
folders:
- map: ~/Documents/Projects //This is the Projects folder location on your computer
to: /home/vagrant/Projects //This is the Projects folder location inside Vagrant.
Configuring sites
Note
The location of your Vagrant folder may vary based on what you set up in the Configuring Shared Folders step. In our example above, we mapped the Vagrant folder to /home/vagrant/Projects
, so our site mapping is pointed towards a folder in that location, therefore /home/vagrant/Projects/myproject
- Scroll down to the
sites
property in yourHomestead.yaml
file - For example, if you want to map your project, named “My Project” to a domain called
myproject.test
, which is in the/myproject
folder in your shared folder, this is how you would configure it in your Homestead.yaml file:
sites:
- map: myproject.test //The domain you'll use to access your "served" site locally
to: /home/vagrant/Projects/myproject //The location of your project's folder in your Vagrant box
Remember to edit your hosts file
Configuring databases
Depending on what you initially named your database during project setup, this is how you can add your database to Homestead:
- In your
Homestead.yaml
file, navigate to thedatabases
property:
databases:
- myproject
Editing the hosts file
- Navigate to and open your hosts file
bash cd /etc gedit hosts
- Add the domain you configured to the end of the file, like this:
192.168.10.10 myproject.test
Reprovision Homestead
Important
Make sure Homestead is already running before you reprovision Homestead.
Do this every time you edit your Homestead.yaml file.
cd ~/Homestead
vagrant reload --provision
Connecting to Homestead via SSH
Make sure Homestead is running
cd ~/Homestead
vagrant ssh
Setting Up A New Project
Laravel
Before starting your project
- Copy .env.example and rename it to .env
- Edit the contents of the .env file:
- APP_KEY
- DB_DATABASE
Set Up Laravel (Optional)
- SSH into Homestead
cd
into project directory- Run command:
bash laravel new [sitename]
Database
Create Database
cPanel
Assign user to database
Generate Key (for .env file)
- Run command
php artisan key:generate
- Copy the generated key into the .env file.
Project Dependencies
Install project dependencies
composer install