Apache Httpd Server



The Apache HTTP Server Project is a collaborative software development effort aimed at creating a robust, commercial-grade, featureful, and freely-available source code implementation of an HTTP (Web) server. Jun 07, 2020 To configure SSL, Apache HTTP must be compiled with modssl. I’ll use CentOS 7 VM from Digital Ocean to demonstrate this. Login to Linux server with root and download the latest version of Apache wget http://www-us.apache.org/dist//httpd/httpd-2.4.25.tar.gz.

  1. Apache Httpd Servername
  2. Apache Http Server Tutorial
  3. Apache Httpd Server Download
  4. Apache Windows Download
  5. Apache Software Foundation
  6. Apache Http Server Tutorial
Skip to end of metadataGo to start of metadata

This is a Recipe for configuring multiple https instances. While writing this recipe I've noticed that there are other pages in this wiki that also deal with this subject, either tangently or in more direct ways:

  • ExtendingPrivilegeSeparation – run several httpd instances behind a reverse proxy, use high ports for the backend instances to improve security
  • DifferentUserIDsUsingReverseProxy – run several https instances behind a reverse proxy, run each instance under an different unprivileged user

Some of the ideas in this recipe have already been advanced in these other wiki pages. However, the focus of this recipe is more on the operating system support (FreeBSD, Ubuntu) for this type of set up. The operating system usually provides facilities, such as rc(8) in BSD systems, or init(5) in Linux and other SysV systems, that help admins in launching processes after sucessfully booting the system.

This recipe, therefore complements those already in the wiki, and provides a step-by-step guide to configure such a setup in a BSD system (FreeBSD) and in a SysV-like system (Ubuntu). Hopefully it can be easily translated to other linux or *BSD flavours.

Note: The Ubuntu section is still a work in progress.


fernan

The Goal

Or: why do we need to run multiple apache instances in one host?

Although you can certainly have a single installation of Apache httpd, running a single instance, and still have different virtual hosts that can be accessed separately, sometimes following this easy path can lead you to a heavy and bloated web server.

If your virtual hosts have different requirements (e.g. mod_perl for one virtual host, mod_python for another, and maybe mod_php for a third virtual host), then your apache instance is almost surely a RAM eater. Remember that httpd will instantly spawn new child processes of the same instance as needed ... if your perl web app is being frequently accessed, why spawn several instances of an httpd process that is also loaded with mod_python, mod_php and an assortment of other modules that, at least from the standpoint of the perl web app, are useless?

The answer to this, is simple: have separate lighter configurations for your mod_perl, mod_python and mod_php apps, listening on different ports (e.g. 81, 82, 83), and have a reverse proxy instance of Apache with virtual hosts configured to pass requests to the corresponding apache instances.

In this recipe, I'll briefly explain how to do something along these lines:
Example: running different web applications listening in different ports, and using a reverse proxy that forwards incoming requests (e.g. blog.company.com, svn.company.com, www.company.com) to the corresponding https instances.

HowTo

How do we configure apache so that we're able to start/stop/restart individual instances?

Apache Httpd Servername

Because apache allows you to load modules dynamically, most of the time, a single installation of apache can serve the needs of multiple instances, and every instance may be configured to run different sets of modules. As an example, you can run a very lightweight proxy module, a mod_perl instance to run your perl web applications, a mod_python instance with DAV to run Subversion, a separate instance running PHP, etc, all from a single local installation of Apache. Unless you have a requirement for a custom built instance (e.g. tweaking compile options differently for different instances), you don't really need to compile and install httpd to different places (prefixes), as many online guides suggest.

In FreeBSD, a clever port maintainer had set up a number of rc scripts that simplify the task of launching all configured instances after booting the system. So if you're using FreeBSD as your server OS, then you're lucky, as the configuration is painless.

In this recipe, therefore, I'll proceed to explain the FreeBSD approach first, and then I'll try to figure out how to do something similar in Linux (Ubuntu).

The FreeBSD approach

1. Install the www/apache22 port

As root, do:

This will fetch the sources for Apache (currently 2.2.17), extract them, and run configure, make and finally install apache-22 on your system. As mentioned before, note that only one local installation is required to run multiple instances of apache. Also note that if you configure the port (make config) to enable mod_perl, mod_python (or any other dynamically loaded module that does not come with the standard apache distribution), then the FreeBSD ports system will 'Do The Right Thing(TM)' and will fetch, extract, configure, make and install the code for the corresponding modules. Easy, huh?

Note also, that there are other alternative ports in FreeBSD that will install different flavours of Apache https:

  • www/apache22-event-mpm
  • www/apache22-peruser-mpm
  • www/apache22-worker-mpm
  • etc.

Choose the port that best fits your needs, and proceed to the next step.

2. Create your apache configurations

In FreeBSD, the configuration files for the recently installed port live in '/usr/local/etc/apache22'. There you will find a sample 'httpd.conf' file. This file may include directives found in other conf files located in a directory called 'extra', at the same location. Please read them, and familiarize yourself with their contents. If you've configured Apache before, you'll find your way around easily.

Now, let's create a number of separate apache configurations. Essentially this means creating different httpd.conf files, for example:

Now edit these files, and tweak the different configurations according to your needs, e.g.

Now, we also need to configure the virtual hosts in the proxy instance, so that whenever a request comes for the Subversion DAV server, it is passed onto your 'python-dav' httpd instance, whereas requests for your wordpress blog are passed to your 'php' instance. Let's edit 'httpd-proxy.conf' again:

So we're finished with the configuration, and now we need to launch all the instances of httpd, and test that everything is working as expected. Of course you can do this using 'apachectl', e.g.

But for production operation, it is safer to rely on the FreeBSD rc scripts. These will make sure that the instances are launched at boot time. Our last stop in this FreeBSD recipe, is therefore:

Apache Httpd Server

3. Edit /etc/rc.conf

The '/etc/rc.conf' in FreeBSD is the master file containing the system configuration information. This file is read after booting the kernel, and serves to launch services, daemons, set up network interfaces, etc. For our recipe we will be enabling the apache server, listing the available instances (profiles), their configuration files, and telling FreeBSD which of these need to be run (enabled) after booting the system.

When these profiles are configured in /etc/rc.conf, and enabled, they will be started after successfully booting the system. If you want to declare a profile but you only want to start the corresponding httpd instance manually, you can just edit '/etc/rc.conf' and say, e.g. :

Later, you can start/stop any httpd instance manually using just the profile name (proxy, perl, python, php), like this:

Apache Http Server Tutorial

Doing it in Ubuntu or Debian

1. Install the apache2 package

In Ubuntu, you need to install not only the apache2 package, but also, the corresponding libapache2-* packages for the modules you need in your apache instances.

2. Create your apache configurations

Apache Httpd Server Download

In Ubuntu, the configuration files for your recently installed webserver are under '/etc/apache2'.
[writing in progress ...]

There is some Debian/Ubuntu specific information in /usr/share/doc/apache2/README.Debian.gz after installation.

3. Configure the system to launch the apache instances after boot

Apache Httpd ServerApache http server tutorial

The Ubuntu/Debian init scripts (e.g. /etc/init.d/apache2) have been updated to support multiple instances of (e.g. multiple configurations, named /etc/apache2-$SUFFIX).

Documentation can be found in /usr/share/doc/apache2/README.multiple-instances

« Apache HTTP Server... | Main | Require and friends »

New in httpd 2.4: If, ElseIf, and Else

Over the coming weeks, I'm going to be writing several articles about new features in Apache httpd 2.4. To me the most compelling reason to upgrade to Apache 2.4 today is the <If> directive, so that's where I'll start.

Related documentation:

This is something that people have been asking for since the very first day I was involved in Apache stuff - the ability to insert conditional statements in configuration files. And now that it's here, it's everything we wanted. Even a bit more.

The <If> directive may be used in all contexts (server config, virtual host, directory, .htaccess) and is evaluated at request time to effect the behavior of the server.

Apache Windows Download

Apache

Some of the things you might use this directive for, you've been using mod_rewrite for up until now, so one of the side-effects of this directive is that we can reduce our reliance on mod_rewrite's complex syntax for common situations. Over the coming months, more examples will be added to the documentation, and we'll have a recipe section with many of the same sorts of scenarios that are in the mod_rewrite recipe section.

Let's start with a few simple examples so that you can see how it might be used. Consider a case where you have a website, www.wooga.com, and you want to compel people to use the www prefix for all requests. In the distant past, you may have used mod_rewrite for this, but here it is stated more clearly with the If directive:

In plain language, that says 'if the host request header isn't www.wooga.com, redirect the request to www.wooga.com.'

In fact, most of the commonest uses of mod_rewrite can now be replaced with the If directive, making them easier to read, and, therefore, less prone to error, and the redirect looping that so often plagues RewriteRule-based solutions.

For more complex scenarios, there's also <ElseIf> and <Else> directives, so that you can create multi-step if ... elseif ... elseif ... else logic flows in your configuration files.

These directives may be used in any scope - main configuration, virtual hosts, directories, or .htaccess files - and so give you significantly more power for conditional configurations than you ever had before.

The term in the If statement can be any request header ($req) or environment variable ($env), or many other values. Expressions in these comparisons can be fairly complicated, as they can use the new expression syntax which is another major enhancements in httpd 2.4, and an article for another day.

As with many features that are brand new in 2.4, you can expect more detailed official documentation in the near future, complete with many examples. For now, I'd encourage you to study the expression syntax documentation, and experiment.

Apache Software Foundation

Posted at 02:34PM Mar 02, 2012 by rbowen in General | |

Apache Http Server Tutorial

Comments are closed for this entry.