Creating virtual Servers in Apache2 using Webmin

I like Webmin. I can edit configuration files, but I have to confess that I don’t memorize the syntax and options, so I only edit configuration files when I need to copy and change something quick.

If I am going to start from scratch, then Webmin is my tool of choice.

I won’t cover in detail how to install Webmin, but here is the short version:

Using apt-get

sudo sh -c 'echo "deb http://download.webmin.com/download/repository sarge contrib" > /etc/apt/sources.list.d/webmin.list' wget -qO - http://www.webmin.com/jcameron-key.asc | sudo apt-key add - sudo apt-get update sudo apt-get install webmin

If you use Yum:

(echo "[Webmin] name=Webmin Distribution Neutral baseurl=http://download.webmin.com/download/yum enabled=1 gpgcheck=1 gpgkey=http://www.webmin.com/jcameron-key.asc" >/etc/yum.repos.d/webmin.repo; yum -y install webmin)

I recently created a few WordPress sites, and I had to create the Virtual Servers for it, and I run into a tiny problem where it was not working correctly. It drove me crazy, but I took some notes.

Using Webmin is easy to create virtual Server. The process is documented in the Wiki at http://doxfer.webmin.com/Webmin/Apache_Webserver#Creating_a_new_virtual_host

However, we all know that we can’t read that much.

To create a Virtual host (virtual Server) go to Servers>Apache Webserver. Then click the tab that says “Create virtual host” (yes, to create a Virtual Server, you create a virtual host).

The options here are pretty simple. VERY SIMPLE!!

Handle connection to address. Basically this is for multi-homed servers more than anything. If you have an IP address per site, here is where you specify it.

Port: This is the tricky part. You would be tempted to put any right? Here most of the time you actually need to listen the port, which most of the time will be port 80.

Why? Well, because in my case I am using a specific server name, and in most cases you would too, so it seems to work better when you set the port instead of just using default (at least with WordPress).

If you need to use https, then you will have to have a certificate per site, and also a IP address per site. So that will change the previous setting. Adding SSL is similar, but the port would be 443, and you need to have mod_ssl enabled too.

Next enter the root location for the site (for WordPress for example it is /usr/share/wordpress).

After that enter the server name. This would be thisismywebsite.com for example

The Add virtual server to file section should be as it is. The default is to add to sites-available, and then it creates the link in sites enabled.

Finally you can copy directives if needed (this is useful when you have special folders, or if using SSL with a wildcard certificate).

Then click on Create Now, and then apply changes. Your site should be working now.

There are more settings, and it is a good idea to refer to Webmin documentation, or the Apache documentation for them, but my most used settings are

Alias and Redirects. I use it when I have sites located under a master root, but the folders are in other parts of the system. I do this a lot to save files in a separate partition.

In Networking and Addresses you can add alternate virtual server names.

Directory indexing is another section you might change, if you need to edit access to files.

Edit directives is basically a quick access to the configuration file for the site. So also useful.

That is it!!! Were you expecting something more complex? You can do more complex, but it is always good start simple, and then more from there. The 2 things to watch out for is port 80 instead of any, and dedicate an IP address per site when using SSL.

Of course there are a ton of configurations changes and mix and match settings, but this way you can quickly have multiple sites running.

Advertisements

If you would like to comment, please refer to which section of the article you liked so I know you are not a spammer. Too many out there :)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s