1. Update the hosts file:
We are going to add an example domain named “thisdayinbangladesh.dev” as a virtual host through this tutorial. Lets first add this in the “hosts” file by typing the following command on the Terminal,
sudo nano /etc/hosts
Then find the following line,
update this to following,
127.0.0.1 localhost thisdayinbangladesh.dev
Also to add our domain to the IPv6 version find the following line somewhere bottom of the file,
update this line to the following one,
fe80::1%lo0 localhost thisdayinbangladesh.dev
Finally press “ctrl+x” and then “y” to save and exit this file.
2. Update httpd.conf file
Open up this file by typing the following command,
sudo nano /Applications/MAMP/conf/apache/httpd.conf
find out the following line,
It might have a “#” symbol at the very beginning of the line. Delete the symbol to activate this statement. If the line is not anywhere of the “httpd.conf” file then add the above line anywhere of this file. Now, save and exit this file.
3. Update httpd-vhosts.conf file
Now go into the “/Applications/MAMP/conf/apache/” folder by executing,
If you can see a folder named “extra” then enter inside it otherwise create this “extra” folder and then enter inside it.
Now update (If there was already a “extra” folder then there should be a “httpd-vhosts.conf” file other wise just create the “httpd-vhosts.conf” file inside “extra” folder) the “httpd-vhosts.conf” file by typing the following,
sudo nano httpd-vhosts.conf
Then the final “httpd-vhosts.conf” file should have the following code block. Whether you add these lines or updated the existing file.
NameVirtualHost *:80 <VirtualHost 0.0.0.0:80> DocumentRoot "/Applications/MAMP/htdocs" </VirtualHost> <VirtualHost *:80> DocumentRoot "/Applications/MAMP/htdocs/thisdayinbangladesh/public" ServerName thisdayinbangladesh.dev <Directory "/Applications/MAMP/htdocs/thisdayinbangladesh/public"> Options All AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
Here “thisdayinbangladesh” is a project directory; actually a laravel4 project directory inside my “htdocs” folder and we added the “public” folder thats resides in “thisdayinbangladesh” folder as the document root cause laravel4 needs to point to the “public” folder as the application root URL.
In this stage of this example. You can forget about laravel4 and simply create the directory “/thisdayinbangladesh/public” inside your “htdocs” folder and place a simple “index.html” file there inside the “public” folder.
Simply stop and re-start the Apache service from your MAMP control panel. Then try out the URL on your browser. http://thisdayinbangladesh.dev You should see your “index.html” file!
This tutorial will take you through out a nice series of posts on which a full laravel4 web application has been developed. That service is already LIVE HERE. So, stay tuned!
The next tutorial is ready Installing Laravel4 in Mac OSX with MAMP. So, you are another step close toward the full laravel4 application development series.