But I have about 5 sites I'm working on, and in PHP that's no problem because there's no real Application Root like in IIS. But I still feel that if you build the site in a subdirectory (like http://localhost/blah) something could be broken when you move it to the web root. So I set up subdomains using virtual hosts in Apache (like http://blah.localhost).
How to do it (the files move around in a bit in other Linux installations)
- In the directory /etc/apache2/sites-enabled place a file called blah using an editor. I use Nano (Pico)
sudo nano /etc/apache2/sites-enabled/blah - In this file I put in these contents. Note that I have chosen what I'm going to call the domain (blah.localhost), where I'm going to put the files and the error logs. Changing these to values you need is obviously the key step here.
ServerAdmin webmaster@blah.localhost
DocumentRoot "/var/blah"
ServerName blah.localhost
ErrorLog "/var/log/apache2/blah-error.log"
CustomLog "/var/log/apache2/blah-custom.log" common - Now we create the DocumentRoot directory
sudo mkdir /var/blah - And modify the hosts file to include blah.localhost. This is not actually necessary, I think, because we have to change this on the host (Windows in this case) anyway:
sudo nano /etc/hosts
And we add a line to hosts which says
127.0.0.1 blah.localhost - Check that it works
ping blah.localhost - Set up a test file for Apache to display
sudo nano var/blah/index.html
with whatever contents you want (Hello Blah!)
- Restart Apache so it picks up the new Virtual Host
sudo /etc/init.d/apache2 restart - Try it out from inside the Guest box
lynx blah.localhost
You should see the Hello Blah page. - Now we set up the Host to see the site. First edit the hosts file. On Windows, this is buried a bit, but you can use
notepad c:\windows\system32\drivers\etc
Add the line
127.0.0.1 blah.localhost - Now open your browser and hit the site
http://blah.localhost:8079/
No comments:
Post a Comment