Forum Moderators: coopster
#######
A while back I asked about creating some sort of alias for developing multiple sites, however I was using absolute urls which was messing things up somewhat. Well last week I found a good soloution:
Virtual Hosts
You will need to add your names in your windows config host file
127.0.0.1localhost red blue
You can find this file here :
C:\WINDOWS\system32\drivers\etc\hosts
Where red and blue will be virtual hosts
Now if you are running some sort of emulator or even linux you will need to edit your httpd.conf file:
You need to add <VirtualHost> container directives
Eg
<VirtualHost *>
ServerName red
ServerAdmin dave@red.com
DocumentRoot C:\red\root\
ErrorLog C:\red\logs\error.log
CustomLog C:\red\logs\access.log combined
</VirtualHost>
<VirtualHost *>
ServerName blue
ServerAdmin dave@blue.com
DocumentRoot C:\blue\root\
ErrorLog C:\blue\logs\error.log
CustomLog C:\blue\logs\access.log combined
</VirtualHost>
You can put just about anything within the containers as you might have on your server. So you could put for following in red to make cgi the default page.
<Location />
DirectoryIndex index.cgi
</Location>
Now when you fire up apache again you should be able to see
The following two addresses
Wondering what has happened to the localhost or 127.0.0.1, well in the httpd.conf the first virtual host in the list will be considered to be the most important.
Hope that helps a bit. Cheers
I just use a config file so the paths resolve themselves by changing one setting, but I could just change one setting in the httpd.conf instead.
Tom
I run a hosts file that contains ALL of my online sites referenced on different local ips. For example:
hosts:
127.0.0.10 webmasterworld.com
127.0.0.11 searchengineworld.com
and on and on.
Then I run a conf file tied to that specific ip:
<VirtualHost 127.0.0.11>
DocumentRoot /www/searchengineworld
ServerName www.searchengineworld.com
ServerAdmin webmaster@searchengineworld.com
ScriptAlias /cgi-bin/ /www/searchengineworld/cgi-bin/
TransferLog logs/sew-access.log
ScriptLog logs/sew-scripterror.log
</VirtualHost>
Add in a simple batch file with a link on my desktop that swaps out the fake hosts file for the real one:
----------------
@rem remove the old file
del c:\windows\hosts
@rem install new
copy c:\windows\hosts.loc c:\windows\hosts
@rem lets go apache
c:\apache\apache.exe
rem done
----------------
And now, I have 100% seamless production in the browser. eg: type in www.webmasterworld.com into my browrser and *presto* up comes WebmasterWorld off of my local disk.
It sure makes perl delevelopment a snap.
btw: this isn't a php thread, it is a PERL thread. lol