Open Source

DIY: Configure Apache with the help of Webmin

Jack Wallen describes how easy it is to configure your Apache server using the Webmin web-based GUI.

Apache is one of the most powerful and flexible web servers available. Although Apache administrators would disagree, to the uninitiated, Apache can be rather overwhelming to configure. For those who really need Apache but don't want to have to fool with the manual configuration of servers, virtual servers, etc., there is a tool called Webmin that makes this job quite easy.

In my recent Webmin tutorial (DIY: Let Webmin handle all your UNIX administration tasks), I didn't go into the configuration of any of the servers, services, etc. In this post, I show how easy it is to configure your Apache server using the web-based GUI. I will assume that you have Apache and Webmin installed on the same machine and that you have admin access to the server.

What you can configure

Through the Apache configuration files, the numbers of configuration options available are astonishing. If you have the time and the inclination, you can do almost anything with your Apache setup (I hear Apache makes a killer cup of coffee!). Within Webmin, those options are pared down to the following and more:

  • Processes and Limits
  • Networking and Addresses
  • MIME Types
  • User and Group
  • CGI
  • Modules
  • Per-directory options
  • Server HTTP header
  • Virtual hosts

Let's dig in to the configuration of Apache. We'll start with solid general options and then make our way to setting up a virtual host -- all with the help of Webmin.

Networking options

Our first configuration options will deal with listening addresses, ports, and timeouts. To get to these options, point your web browser to the Webmin admin tool, log in, and click the Servers listing (left nav) to reveal the Apache Webserver link. Click the Apache link to reveal the main Apache configuration page (Figure A). Figure A

By default you will land on the Existing Virtual Hosts tab. If no hosts exists, that tab will be blank. (Click the image to enlarge.)
Click the Global Configuration tab. As you might expect, the configurations found under this tab affect the entire server. From the Global Configuration tab (Figure B), click the Networking And Addresses icon. Figure B

You can also examine and edit the configuration file through a virtual terminal within Webmin by clicking the Edit Config Files link. (Click the image to enlarge.)
In the Networking And Addresses section (Figure C), you can set the specific address and port that Apache listens on. Figure C

After you save the changes, make sure you click the Apply Changes link in the upper right corner. (Click the image to enlarge.)

MIME types

One Apache configuration that trips people up a lot is the MIME types. This happens quite often when people try to set up a server to serve up dynamic .php files. Instead of serving the files, Apache won't realize those files are to be executed and simply display them. To avoid this, you would need to add a php MIME type, which you can do by following these steps:

  1. Click the Global Configuration tab and then click the MIME Types link.
  2. In the new page, scroll all the way down to the bottom and click the Add a New MIME Type button.
  3. On this new page (Figure D), enter the details for the MIME type and click Save.

Figure D

If you're unsure of the details for the MIME type, google it so you enter the correct information for the type you want to include. (Click the image to enlarge.)

Virtual host

One of the most powerful Apache features is virtual hosts. To the untrained user, these can be really intimidating, unless you're using Webmin for the setup.

Before you go to Webmin to set up the virtual host, you must create the directory to be used for the virtual host. Where and what this directory is will be entirely up to your setup and your needs, but make sure the webserver has permission to get into the directory. The permissions need to be 0755, so set them with the command chmod -R 0755 /path/to/directory (/path/to/directory is the path to the newly created directory).

Now go to the Apache Server page within Webmin and click the Create Virtual Host tab. From this page (Figure E), you can set up the entire virtual host in just a few quick seconds. All you need to configure is:
  • Document Root: The path to the new directory.
  • Port: If you need this virtual host served up on a non-standard port.

This is the basics; you can fine-tune the virtual host, but the defaults should work out of the box.

Figure E

Remember, if you use a non-standard port, that port must be available on your network (if it's being blocked, the new virtual server will not be seen). (Click the image to enlarge.)
There's one last configuration to make. Go back to the Existing Virtual Hosts tab and click the link for the virtual host you just created. In this page (Figure F), click the Networking And Addresses link and, if you need, add any alternate virtual server names for your new virtual host. Figure F

Adding alternate virtual server names is optional, though it can make host-based naming much easier. (Click the image to enlarge.)

After you make any changes, click Save and then Click Apply changes. You now should have a working virtual host set up on your Apache server, thanks to the simplicity of Webmin.

About

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.

1 comments
pgit
pgit

Getting php working with apache can be a show stopper. Beyong recognizing the mime type, there has to be a working php environment and apache has to be aware of it. Complicating the issue is when you look to install "php," the casual user is immediately slapped upside the head with what looks like 300+ packages. If you install them all, it's guaranteed the php environment won't work. So what to install? I found a simple workaround a long time ago: dokuwiki. (other similar apps will do, but this one is minimalist, simple and a wiki is useful in it's own right) Just install the latest dokuwiki in your apache root and go through the setup. It brings on board the basics needed to get php working, the basic files and the configuration. If you need any php functionality beyond that (usually not) then add whatever extra packages. But do so sparingly, one at a time. If you go overboard with php features you'll have an unworkable mess on your hands.