Configuring, Tuning and Debugging Apache
Until now, we have assumed our Apache installation is statically compiled, with all of the modules placed inside of Apache at compile time. This is the traditional way to compile Apache, and the default if you simply perform a “./configure”.
The problem with the above configuration is that it is relatively inflexible. What happens if you discover that you forgot to configure Apache to include a particular module? You will have to recompile the entire program, specifying which modules you do and don't want to include when running configure. This does not seem bad at first—after all, how often will you want to add a new module to the system?
However, the problem is deeper than that, in at least two ways. Why should Apache consume memory for modules that might not be used? In addition, why should I have to recompile Apache every time a new version of just one module is released?
In order to solve this problem, the Apache developers now support a system known as DSO, or “dynamic shared objects”. DSOs make it possible to compile Apache with only two statically linked modules, mod_core (which provides core functionality) and mod_so (which handles the loading of DSOs). All other modules can be built such that they are loaded only when necessary. Because modules are not an inherent part of Apache, they can also be upgraded without having to recompile the web server itself. As we will see below, this functionality can come in handy if you need to upgrade or debug an already-running and configured Apache server.
To compile Apache with DSOs, you will need to decide which modules you wish to compile statically, and which you will compile as DSOs. My preference is to make everything a DSO, but to compile only the modules that Apache installs by default. We can do this by changing our invocation of “configure”:
This will automatically enable mod_so, and will compile Apache with all of the default modules. After compiling Apache with make and installing it with make install, Apache will continue to work as before. The only difference is that it can now load modules dynamically, adding new modules to the already-compiled HTTP server as they are needed.
The default httpd.conf created by an Apache server compiled with --enable-shared looks slightly different from that created for a statically compiled Apache server. For one, most of the directives are hidden inside <IfModule> sections, making it possible for Apache to load even if some of its modules have not been loaded yet. In addition, each module must first be loaded with the LoadModule directive, and then enabled with the AddModule directive. For example:
LoadModule perl_module libexec/libperl.so AddModule mod_perl.c
LoadModule takes two arguments, the name of the module and the file in which the .so file sits. The name must match the name with which the DSO module was compiled, while the file name should point to a directory relative to /usr/local/apache. In the above example, and by default, DSO modules are placed in /usr/local/apache/libexec.
In contrast with most of the other directives in httpd.conf, LoadModule and AddModule are sensitive to the order in which they are placed. LoadModule must come before AddModule, and each module must be loaded and added before its directives will work. In addition, some modules must be loaded before others, and will not work otherwise. If it is possible to let an automatic configuration tool take care of the insertion of LoadModule and AddModule, let it do so. This may save your web server from hard-to-track-down configuration problems.
Once Apache is compiled with DSO support, new modules can be added at any time. However, these modules must be compiled with the same configuration information that was present when the Apache server itself was compiled. This is handled automatically by apxs, the “Apache Extension” program, written by Ralf S. Engelschall. apxs makes it possible to compile an Apache module into a DSO (.so file), and then to install it into the appropriate Apache configuration. Unfortunately, there seems to be little or no documentation for apxs, meaning that it can be difficult to understand exactly what this program does or how it works.
For example, let us assume we have already compiled and installed Apache with DSO support. Several weeks later, we notice that many of the hits on our site are resulting in “file not found” errors, because users cannot spell the odd names we have used in our URLs. One solution is obviously to revamp the site such that users will be able to spell things more easily. But an easier solution is to install mod_speling, so capitalization and spelling are largely ignored.
To compile mod_speling as a DSO, type:
/usr/local/apache/bin/apxs -c mod_speling.oc
apxs will invoke gcc, compiling mod_speling. The result will not be directly executable, but rather a library that can be invoked by Apache. If the compilation was successful, then we can install mod_speling with the following command:
/usr/local/apache/bin/apxs -i -n -a mod_speling.soUsing apachectl configtest is particularly useful when installing new DSO modules. It ensures that the module we have added is indeed there and working, and that Apache now understands any new directives we added outside of <IfModule> sections.
Practical Task Scheduling Deployment
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.View Now!
|The Firebird Project's Firebird Relational Database||Jul 29, 2016|
|Stunnel Security for Oracle||Jul 28, 2016|
|SUSE LLC's SUSE Manager||Jul 21, 2016|
|My +1 Sword of Productivity||Jul 20, 2016|
|Non-Linux FOSS: Caffeine!||Jul 19, 2016|
|Murat Yener and Onur Dundar's Expert Android Studio (Wrox)||Jul 18, 2016|
- The Firebird Project's Firebird Relational Database
- Stunnel Security for Oracle
- My +1 Sword of Productivity
- SUSE LLC's SUSE Manager
- Non-Linux FOSS: Caffeine!
- Managing Linux Using Puppet
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- Parsing an RSS News Feed with a Bash Script
- Google's SwiftShader Released
- Doing for User Space What We Did for Kernel Space
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide