Setup virtualhost in Apache on Solaris 10
May 28, 2008 11:10 am apacheThis one took a long time, There are loads and loads of examples out there but not all of them will work for your solution depending largely on what OS and version of Apache you are using. I am using Solaris 10 U4 and Apache 2.0.58.
You only need to amend 2 files. /etc/hosts and your Apache’s httpd.conf, which in my case is /usr/local/apache2/conf/httpd.conf.
In /etc/hosts add the ip address and fqdn of the apache2 servers. So on my host anouk, which has an ip address of 192.168.0.23 i would add the following:
192.168.0.23 anouk.dynalias.com
192.168.0.23 elthamauskick.dynalias.com
Next is the httpd.conf file. Vi and shift-g to scroll to the end of the file, which is the virtualhost section. This is what i added:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /work
</VirtualHost>
<VirtualHost *:80>
Servername anouk.dynalias.com
ServerAdmin mglas72@gmail.com
DocumentRoot /work/html
DirectoryIndex index.html index.php
Redirect /index.html http://anouk.dynalias.com/mgblog
</VirtualHost>
<VirtualHost *:80>
Servername elthamauskick.dynalias.com
ServerAdmin mglas72@gmail.com
DocumentRoot /work/html/auskick
DirectoryIndex index.html index.php
</VirtualHost>
And from here you could add as many virtualhosts as you would like. Note that inside each virtualhost you can add almost any Apache directive, but directives listed in other parts of the httpd.conf will be ignored if a virtualhost is found. The top virtualhost in the above example is used to capture any requests that fall out of the two virtualhost domains, so it displays an error message contained in /work.
With all the options available you will undoubtedly require the documentation, here is the link: http://httpd.apache.org/docs/2.0/vhosts. Google, as always, is your friend. One last little tip, use the /usr/local/apache2/bin/httpd -S if you are having trouble, it will provide you with parsing info on the httpd.conf file.