Home arrow Apache arrow Page 13 - Getting Started with Apache

Testing the Server Configuration Without Starting It - Apache

Learn the basic steps necessary to download, install, and configure a basic Apache server. This article is from chapter two of Pro Apache by Peter Wainwright. (Apress, 2004, ISBN: 1590593006).

  1. Getting Started with Apache
  2. Installing Apache
  3. Installing Apache from Binary Distribution
  4. Installing Apache from Prebuilt Packages
  5. Installing Apache by Hand
  6. Upgrading Apache
  7. Basic Configuration
  8. Administrator’s E-Mail Address
  9. Starting, Stopping, and Restarting the Server
  10. Generic Invocation Options
  11. Windows-Specific Invocation Options
  12. Testing the Server
  13. Testing the Server Configuration Without Starting It
  14. Using Graphical Configuration Tools
By: Apress Publishing
Rating: starstarstarstarstar / 19
December 13, 2004

print this article



If you want to check that Apache’s configuration is valid without actually starting the server, you can do so by passing the server executable the -t option. The following uses a Unix installation path as an example:

$ /usr/local/apache/bin/httpd -t

This will report any problems with the configuration or return a “Syntax OK” message if all is well. If you included any directories into the configuration, then you’ll also get a list of the configuration files Apache found and processed. The document roots of the primary server and any virtual hosts you have created are also checked, and a warning is issued in each case if the associated directory is not present. You can disable this check by using the -T option, which is in all other respects identical to -t:

$ /usr/local/apache/bin/httpd -T

You can also use apachectl, which will test the configuration inclusive of document root checks using the configtest mode:

$ apachectl configtest

To test a Windows service configuration, use the -t or -T options in conjunction with -n:

c:\> apache -n Apache2 -t

This is just a convenience wrapper around a call to the server executable using -t; in a default installation, it’s identical to the first command given previously. If you want to change it to -T or add a corresponding configtestnoroot mode, then it’s simple to adapt apachectl accordingly.

Windows installations performed by the installer additionally create a menu item to test the configuration.

Getting the Server Status from the Command Line

If you have mod_status configured into the server, you can also test it from the command line using apachectl and the status or fullstatus options. These extract a status report from the server:

$ apachectl status

or for a full status report (note that this option is called extendedstatus in earlier versions of apachectl):

$ apachectl fullstatus

Nice though this seems, it’s really just a wrapper around a conventional HTTP request that you might equally have made with a browser or a telnet command. As such, it will work only if apachectl is configured to point to a URL that will return a status page. If you have modified how and where a status page is delivered, you’ll need to modify apachectl. In addition, apachectl uses an external program, by default the text-only Lynx browser, to actually do the work, so the fullstatus option is actually equivalent (on a default Unix installation where the port is set to 80 with Listen or Port) to the following:

lynx -dump http://localhost:80/server-status

This is actually what the default Apache configuration responds to, so out of the box it should work (so long as you have Lynx actually installed, of course). In addition, if you build Apache with a different initial configuration—for instance, a different default listening port or a different name for the server binary—then apachectl will be installed with that port number or server name preset in the program.

It’s entirely possible and actually easy to extend apachectl to produce other kinds of test reports, for instance, adding the apachectl info command to retrieve the information page produced by mod_info. You just need to add a clause for info and maybe add an INFOURL constant at the top of the program. After viewing the apachectl script in an editor, the changes to make should be self-evident. Given time, it’s possible and quite appealing to turn apachectl into a custom Web server tuning and monitoring tool. 

This chapter is from Pro Apache by Peter Wainwright. (Apress, 2004, ISBN: 1590593006). Check it out at your favorite bookstore today. Buy this book now.


>>> More Apache Articles          >>> More By Apress Publishing

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Apache Unveils Cassandra 1.2
- Apache on ARM Chips? Dell and Calxeda Help M...
- The Down Side of Open Source Software
- VMware Unveils Serengeti for Apache Hadoop
- SAP Takes Steps to Improve Hadoop Integration
- Looking to Hone Apache Hadoop Skills?
- How to Install Joomla on WAMPP
- Working with XAMPP and Wordpress
- GUI Available for Apache Camel
- Reduce Server Load for Apache and PHP Websit...
- Creating a VAMP (Vista, Apache, MySQL, PHP) ...
- Putting Apache in Jail
- Containing Intrusions in Apache
- Server Limits for Apache Security
- Setting Permissions in Apache

Developer Shed Affiliates


Dev Shed Tutorial Topics: