Archive for the 'General' Category

Configuring Apache 2.0.X - Virtual Hosting

Tuesday, February 5th, 2008

What is virtual hosting? Well, as we discussed in setting up dns and how dns works, you might be wondering that if every domain and subdomain has it’s own ip address then, wouldn’t we run out of ips? Yes. Of course! But, the cool thing about virtual hosting is that you can place multiple domains on the same ip. The only exception to this is SSL which requires it’s own ip address for each certificate. So, how do you setup virtual hosting? First thing, make sure all your domains or subdomains point to the same ip address in your dns settings.

So for example if your ip was 127.0.0.1 then: tech.mydomain.com , www.mydomain.com and blog.mydomain.com should all point 127.0.0.1 .

Next, let’s go to your apache configuration (httpd.conf) file.

In httpd.conf let’s go to the bottom of the file an add the following,

NameVirtualHost *

<VirtualHost *>
ServerAdmin webmaster@mydomain.com
DocumentRoot c:/home/webpub/tech.mydomain.com/
ServerName tech.mydomain.com
ErrorLog c:/home/logs/tech.mydomain.com-error.log
CustomLog c:/home/logs/tech.mydomain.com-access.log common
</VirtualHost>

<VirtualHost *>
ServerAdmin webmaster@mydomain.com
DocumentRoot c:/home/webpub/blog.mydomain.com/
ServerName blog.mydomain.com
ErrorLog c:/home/logs/blog.mydomain.com-error.log
CustomLog c:/home/logs/blog.mydomain.com-access.log common
</VirtualHost>

<VirtualHost *>
ServerAdmin webmaster@mydomain.com
DocumentRoot c:/home/webpub/www.mydomain.com/
ServerName mydomain.com
ServerAlias *.mydomain.com
ErrorLog c:/home/logs/www.mydomain.com-error.log
CustomLog c:/home/logs/www.mydomain.com-access.log common
</VirtualHost>

Let’s review over what we did.

NameVirtualHost *

This tells us we will run virtual hosts on all ips and ports.

<VirtualHost *>
ServerAdmin webmaster@mydomain.com
DocumentRoot c:/home/webpub/tech.mydomain.com/
ServerName tech.mydomain.com
ErrorLog c:/home/logs/tech.mydomain.com-error.log
CustomLog c:/home/logs/tech.mydomain.com-access.log common
</VirtualHost>

This snippet tells apache to setup a virtual host that answers to the name tech.mydomain.com with the path for the documents  being c:/home/webpub/tech.mydomain.com/. If you look at the end of the configuration changes you will see an additional parameter for the virtual host mydomain.com.

The parameter ServerAlias allows you to assign domain aliases so that multiple domains or subdomainscan point to the same virtual host setup. So, for example, by placing this snippet last:

<VirtualHost *>
ServerAdmin webmaster@mydomain.com
DocumentRoot c:/home/webpub/www.mydomain.com/
ServerName mydomain.com
ServerAlias *.mydomain.com
ErrorLog c:/home/logs/www.mydomain.com-error.log
CustomLog c:/home/logs/www.mydomain.com-access.log common
</VirtualHost>

This will tell apache that after directing people to blog.mydomain.com or tech.mydomain.com, everything else should be directed to www.mydomain.com. In this case the * is a wildcard. You could also setup ServerAlias to be ServerAlias *.mydomain.com *.myotherdomain.com which would allow anything from either domain to use the same document root c:/home/webpub/www.mydomain.com/ while tech and blog use a different one.

As you can see, this is a very powerful tool for setting up large numbers of websites, each with their own path on your system.

Why Apache webserver?

Thursday, January 31st, 2008

Even if you’re running windows as your hosting platform, I’ve always like Apache as webserver for the pure reason that it’s incredibly flexible and powerful. Granted IIS is as well but I’ve spent the majority of my time on configuring and stabilizing Apache so that’s what I will focus on in these articles. Also if you learn to configure and work with Apache, you will have an easier time in the future if you switch to a non-windows platform such as RedHat Linux.

Apache is a key ingredient in configuring your hosting platform.  It will serve up pages from your domains and will allow you to build dynamic sites.  Out of the box it will let you password protect directories, setup virtual hosts, specify multiple paths, etc. There are hundreds of plugins for it allowing for different languages such as Java/PHP/Python/Perl and even .NET applications to run on it. You can use Apache as proxy for web surfing as well. So, that’s why in a nutshell I lean toward Apache as a webserver.

Goals & Visions

Tuesday, January 29th, 2008

What are my goals with this blog. Well, besides dispensing with useful advice and technical information, I’d like to try to publish at least one article per business day and on the occasional weekend. Also, I’ll answer people’s questions, both technical and non-technical in relation to building websites, coding or hosting.

Welcome

Monday, January 28th, 2008

Welcome! So what’s this blog all about. Well, I’ve been in the hosting business for well over 7 years in some capacity or another. Most of my experience has been on windows but with many open source and pay software ranging from web servers / email servers and ftp servers. I hope to be able to give some great advice here on resolving issues and questions that come up. This site is more geared toward someone who wants to build their own machines, host them in their own data centers and come up with decent practices to handle clients.