Creating New Sites with Homestead & Laravel on Mac OSX

If you’ve previously installed Homestead on your local OSX machine and have a few sites running on the same Vagrant box, this guide is a reminder on how to add additional sites.

In a text editor or Bash Nano, edit the

~/.homestead/Homestead.yaml file.

Append the new sites under ‘folders’ and ‘sites’.

In Terminal, navigate to your Homestead sites directory, eg:

$cd /Users/Harrold/Sites/Homestead/sites

Create the new Laravel project, eg:

$ laravel new project-name

The project-name is the folder name from your .yaml folder map

Reload Vagrant for the changes to take effect

$ vagrant reload

SSH into Vagrant:

$ vagrant ssh

Navigate to the Laravel project, eg:

$ cd /home/vagrant/project-name

Run Composer Install to download Laravel’s dependencies.

$ composer install

Setup the .env file

$ mv .env.example .env

Generate the Laravel application key:

$ php artisan key:generate

If necessary, set the permissions:

$ sudo chgrp -R www-data storage bootstrap/cache
$ sudo chmod -R ug+rwx storage bootstrap/cache

You may need to manually set up the Nginx Server Blocks, remembering to setup the symlinks:

$cp /etc/nginx/sites-available/old-site /etc/nginx/sites-available/another-site

$ sudo nano /etc/nginx/sites-available/old-site

$ ln -s /etc/nginx/sites-available/another-site /etc/nginx/sites-enabled/another-site

$ sudo nginx -t

$ sudo service nginx reload

Navigate to the site in the browser to hopefully see a Laravel home page!

Edit the welcome page to check the Server Blocks are pointing to the correct site.

Bookmark the dev URL in the browser, and the Database connection in the DB GUI.

Setup the databases and other Laravel stuff and configure the app/config etc.

 

Leave a Reply