Installing And Configuring Laravel Homestead. In 2014, Laravel took another major step towards popularization – the Homestead Vagrant box was introduced to the community.
In simple terms, we have presented a virtual machine tailored for development in Laravel.
Homestead allows you not to think about which operating system the project will be developing on since it provides full support for all common operating systems (Windows, Mac, Linux) and stuffing with everything you need for development.
This fact can especially please novice web developers working on Windows, because in the future when they grow to develop for Linux, thanks to the cross-platform nature of this virtual machine, the transition process will be greatly simplified.
Table of Contents
What’s in Homestead?
- Ubuntu 14.04 is an open-source operating system based on Linux.
- PHP 5.6 – did not manage to get through the release of the new PHP version in the summer of 2014, and support for this standard was already included in the base assembly of our Vagrant box.
- Nginx is a simple and reliable web and proxy server.
- MySQL – if anyone else knows, this is a database management system.
- Postgres – Another Database Management System
- Node is a framework for executing JS.
- Redis is a non-relational database management system.
- Memcached is a data caching service.
- Beanstalkd is a mechanism used to perform background tasks.
- Laravel Envoy – allows you to work with SSH tasks.
- Fabric + HipChat Extension
Installation and configuration
Let’s review using Windows as an example.
Installation
We start the installation by downloading and installing Vagrant and VirtualBox. This step is the easiest. These products are installed as the most common applications on all common operating systems, so let’s go straight ahead.
Vagrant will ask you to restart the system. At this stage of the installation, there is one caveat – when you restart, you need to go into the BIOS and check that the Intel Virtualization Technology (VT-x) hardware visualization functionality is connected.
For further installation, we will use the console (I recommend Git Bash, a handy thing for many tasks).
By command:
vagrant box add laravel / homestead
Add our laravel / homestead box to Vagrant.
The file is large enough that the download process may take some time.
In order not to lose it in vain, we will immediately copy the storage with the configuration files to the folder in which our working projects will be located later, for example: C: / Users / MyName / MyProject
The command for this action:
git clone https : //github.com/laravel/homestead.gitgithub . com / laravel / homestead . git
Customization
Further:
bash init. sh
This is how Homestead.yaml is created. It contains the basic settings that are required afterward to create a local machine. It is located in ~ / .homestead (C: \ Users \ username \ .homestead in Windows)
We open our .yaml and write the path to the public SSH key in authorize, and write the path to the private key in keys. To create it, write in Git:
ssh-keygen – t rsa – C “[email protected]”
Next, in folders, specify the paths to the folders that we can use inside Homestead (folders with our projects). By this action, we synchronize folders and files contained inside the local and virtual machines.
An interesting aspect for many developers can be support for launching their projects in the HHVM environment, especially considering that for this it is enough to use just one command:
sites: – map: homestead. app to : / home / vagrant / Code / Laravel / public hhvm : true
Adding new aliases will not pose any particular problems either. To do this, just find ~ / .homestead in our virtual machine and use the aliases.
The domains with which we will work must be registered in the hosts file (in Windows it is located in the directory: C: \ Windows \ System32 \ drivers \ etc \ hosts)
An example of a line to be added:
146. 124 . 10 . 10 my – site . local
The numbers at the beginning are the ip from Homestead.yaml, followed by our custom domain. Now we can go to the site we created using the browser.
With your local machine set up, it’s time to connect Vagrant. It’s easy to do this from within Homestead:
vagrant up
This command will synchronize folders, configure Nginx according to our settings, and launch the virtual machine.
It is worth reading before starting development
Vagrant related commands are executed from the homestead directory.
To establish an SSH connection, use:
vagrant ssh
There are a couple of ways to connect to the next project. The first one uses our virtual machine:
vagrant ssh
serve new. dev / home / vagrant / Workspace / new / public
Second, we go to our Homestead.yaml, find sites there, prescribe what we need to add following the template from the example, run:
vagrant provision
Profit, site added.
It is worth paying attention to the fact that a number of port redirects are used within this assembly :
Protocol Local port number Virtual port number
SSH 2222 22
HTTP 8000 80
MySQL 33060 3306
Postgres 54320 5432
It is also useful to remember that the development environment we offer uses two well-known DBMSs: MySQL and Postgres. In Laravel, everything is initially configured in order to get started right away without bothering about it. For those who are interested, I will say that by default it uses the ports of the virtual machine since it is located inside it, so for MySQL, it is 3306, and for Postgres 5432 ports.
If we need to configure another client to work with the database, then we need to use IP 127.0.0.1 and ports 33060 from 54320 for MySQL with Postgres, respectively. The login will be for both homestead bases, and the password will be secret.
For professional services or consultation from GCC Marketing Dubai please Contact Us or call us directly on 00971567300683