03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Multisites 199<br />

This line tells the operating system to send requests to dev.tutorial to 127.0.0.1. You’ll want to<br />

replace 127.0.0.1 with the IP address of the server you are using for this tutorial (assuming it’s<br />

not LAMP/MAMP on your local machine) and dev.tutorial with whatever you want the virtual<br />

host to be.<br />

.<br />

You’ll need to repeat this process for each virtual host you add. If your application has (for example)<br />

three different domains pointing to it; then you will need to set three of these up to test them locally.<br />

Creating Apache 2 Virtual Hosts<br />

Apache2 virtual host entries are created by manipulating the configuration files usually located in<br />

/etc/apache2/sites-available/. You can edit the default file, and add the entries to it, or you can<br />

create new files.<br />

.<br />

If you choose to create new files for your virtual host entries, then you will need to symlink them<br />

to /etc/apache2/sites-enabled/* where ***** matches the name of the files you create in the sitesavailable<br />

folder.<br />

The expanded syntax of virtual host entries can be quite a bit to type/maintain; so I have a few go-to<br />

lines I usually use:<br />

1 <br />

2 DocumentRoot /var/www/site1<br />

3 ServerName dev.site1<br />

4 <br />

.<br />

This was extracted from /etc/apache2/sites-available/default.<br />

The ServerName property can be anything you like — it’s the address you will use in your browser.<br />

The DocumentRoot property needs to point to an existing folder in the filesystem of the web server<br />

machine.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!