2.Vagrant
Select a folder for your develpment code.
Add the below alias to your ```~/.bashrc``` file or ```~/.bash_profile`````` alias lamp="curl -L -o 'install.sh' https://goo.gl/xQR4ud && curl -L -o 'Vagrantfile' https://goo.gl/TMPyh2 && vagrant up" ```
Provide source to your ~/.bashrc
file or ~/.bash_profile
Ex : source ~/.bashrc
This will take a few minutes as your intenet connection.
RUN ```vagrant up``` to start your virtual dev machine.You can connet to ssh by the below command
vagrant ssh
Now, All is set.
If you cd to /vagrant, this folder will be shared with your project root on your local/host machine. That means, when you create a file on your Mac, it will instantly be shared (both ways) with the /vagrant directory on your VM. However, we're also syncing with the /var/wwwdirectory on your VM, which is the Apache root. That means, if you visit http://192.168.33.21
, you should see "It Worked!" You can change the IP address in your Vagrantfile, if you need to.
Have fun! This also installs and enables X-Debug for you. You can stop using MAMP now.
Edit your hosts file to set a simpler address, like http://app.dev/. ``` sudo vi /etc/hosts ``` At the bottom of this file, add:192.168.33.21 app.dev
Now, browse to http://app.dev.
$ vagrant ssh
$ sudo vim /etc/apache2/sites-available/000-default.conf
(Change `DocumentRoot /var/www/html` to `DocumentRoot /var/www`)
$ sudo service apache2 reload
Reload the browser. Now, your local project root will be treated as Apache's document root. Typically, though, you'll want to set Apache's document root to something like the public directory - so DocumentRoot /var/www/public
.
For this example, maybe we're building a new app, called "Larabook." Begin by creating a new directory, "larabook" within the same directory that has the Vagrantfile that you pulled in during Step 3. Add a dummy index.php file here, just to prove that it's working.
$ vagrant ssh
$ cd /etc/apache2/sites-available/
$ sudo cp 000-default.conf larabook.conf
Open `larabook.conf, and set:
ServerName larabook.local
DocumentRoot /var/www/larabook
sudo a2ensite larabook
sudo service apache2 reload
Enjoy development with PHP.
Make an alias that points this your folder. edit your : ```source ~/.bashrc```alias dev-up="cd ~/Code; vagrant up"
Get ssh rights to machine
alias dev-ssh="cd ~/Code; vagrant ssh"
you can add your custom aliases to make your work much easy.
Thanks to Jeffrey Way