Last active
November 10, 2015 21:48
-
-
Save thomasbabuj/336f67d22bedb36ff147 to your computer and use it in GitHub Desktop.
Laravel Homestead Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Laravel Homestead is an official, pre-packaged Vagrant "box" that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine. | |
Pre Included Softwares | |
Ubuntu 14.04 | |
PHP 5.5 | |
Nginx | |
MySQL | |
Postgres | |
Node (With Bower, Grunt, and Gulp) | |
Redis | |
Memcached | |
Beanstalkd | |
Laravel Envoy | |
Fabric + HipChat Extension | |
Installation & Setup | |
Installing VirtualBox & Vagrant | |
Download Virtual Box :https://www.virtualbox.org/wiki/Downloads | |
Vagrant :http://www.vagrantup.com/downloads.html | |
Adding The Vagrant Box | |
Once VirtualBox and Vagrant have been installed, you should add the laravel/homestead box to your Vagrant installation using the following command in your terminal. | |
vagrant box add laravel/homestead | |
Clone The Homestead Repo | |
Once the box has been added to your Vagrant installation, you should clone or download this repository. | |
git clone https://github.com/laravel/homestead.git Homestead | |
Setting up SSH key , Configure share folders and Ngnix sites | |
Edit the Homestead.yaml file included in the repository. | |
authorize: /Users/<computername>/.ssh/id_rsa.pub | |
keys: | |
- /Users/<computername>/.ssh/id_rsa | |
folders : ( this for shared folders ) | |
- map: <Your local file folder path> | |
to: /home/vagrant/Code ( this is pointing to the virtualbox folder ) | |
sites: | |
- map: homestead.app -- is the default site map | |
to: /home/vagrant/Code/Laravel/public - this is the path of the Laravel public folder | |
Note: Don't forget to add the "domains" for your Nginx sites to the hosts file on your machine! The hosts file will redirect your requests for the local domains into your Homestead environment. | |
Mac and Linux, this file is located at /etc/hosts. | |
127.0.0.1 homestead.app | |
We can config multiple sites here, so the sites section will looks like, | |
sites: | |
- map: client1.app | |
to: /home/vagrant/Sites/Client1/public | |
- map: client2.app | |
to: /home/vagrant/Sites/Client2/public | |
Launch The Vagrant Box | |
Once you have edited the Homestead.yaml to your liking, run the vagrant up command from the Homestead directory in your terminal. | |
you can access the site via your web browser on port 8000! | |
http://homestead.app:8000 | |
Note: While your trying to access the site from your browser using about url, you will see "No input file specified" | |
this is because, When you set up the folder that is to be shared with Vagrant, that is just the base folder for all projects on the Homestead vagrant machine. The first time you set it up, no folders exist inside of the Code folder because you haven't created any new projects yet. This configuration allows you to have multiple projects mapped to the same vagrant machine and have them use the same folder structure as before. | |
So, the sites entry says that it is supposed to map homestead.app to /home/vagrant/Code/Laravel/public. | |
The problem is that the folder/project Laravel doesn't exists in the Code folder on either vagrant or host machine. If you set it up exactly like the yaml file says and then install a new laravel project in the folder Laravel on either the host or vagrant machine, it will work. | |
If you want to use composer on the vagrant machine you can just ssh into the vagrant machine by typing vagrant ssh into your terminal or command shell. | |
Once there, navigate to the base folder ( cd Code folder ) that you setup in the folders entry and use composer to create a new laravel project. | |
composer create-project laravel/laravel Laravel --prefer-dist | |
This command inside the Code folder on the vagrant machine will install laravel into the correct folder for the default configuration to work. If you have composer already installed on your local machine, you can just go to the folder that you mapped to /home/vagrant/Code and run the composer command from above. | |
Connecting to your database | |
To connect to your MySQL or Postgres database from your main machine via Navicat or Sequel Pro, you should connect to 127.0.0.1 and port 33060 (MySQL) or 54320 (Postgres). The username and password for both databases is homestead / secret. | |
Ref: | |
1) http://laravel.com/docs/homestead | |
2) http://laravel.io/forum/06-04-2014-no-input-file-specified-using-homestead | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment