|
|
To print: Select File and then Print from your browser's menu
-------------------------------------------------------------- This story was printed from ZDNet Australia. --------------------------------------------------------------
|
Apache setup and configuration By Shylon Ray Hunter, Builder.com September 18, 2002 URL: http://www.zdnet.com.au/news/communications/soa/Apache-setup-and-configuration/0,130061791,120268318,00.htm
Apache is open source, powerful, free and runs on more than half of all Internet servers. Let's take a quick look at how to get your Apache server up and running. As a developer, I find it imperative to know the products that I'm working with; you need to know how to set up and configure your own Web server for development and possibly production. Downloading Apache
At this time, there are two versions of Apache: 1.3.26 and 2.0.40. I used version 1.3.26 in this article, because I use Apache with PHP and there are some issues with Apache 2.0 and PHP. As with any download, I suggest validating it against the provided PGP keys, or at least against the MD5 hashes provided by Apache. Apache installation and setup
The most used options include installation, configuration, and suEXEC options. The installation layout options let you pick where specific Apache files and directories will be installed on your system. For example, you can specify where the cgi-bin or htdocs directory will be created. The configuration options install or disable specific modules, enable or disable certain rules, or configure Apache with third-party modules. The features associated with suEXEC can be found under the options with the same name. With that said, let's get started with our demonstration of a common Apache configuration. We'd enter the following command string: $ ./configure --prefix=/usr/local/apache-1.3.26 \ --activate-module=src/modules/php4/libphp4.a \ --disable-module=autoindex \ --enable-module=so \ --with-perl=/usr/bin/perl The above configuration will give you some options from the various groups. Here's a quick breakdown of what's happening:
After running the configuration script, we can move on with the following commands: $ make $ su $ make install If everything goes well, you should be able to run and stop Apache. You can use the following commands: To start apache: $ PREFIX/bin/apachectl start To stop apache: $ PREFIX/bin/apachectl stop So now that you have Apache up and running, it's time to review and modify the Apache configuration file, httpd.conf. Configuring Apache To configure Apache, we need to edit the file httpd.conf that's found in the conf directory under the PREFIX directory. In our example install, the httpd.conf file will be located under this directory /usr/local/apache-1.3.26/conf/. You can edit the file with an editor of your choice. For a full listing of all the run-time directives that may be specified in the configuration file, check out the Apache Web site. Most directives follow this common format:
Let's cover a few directives that we'll want to change, beginning with the ServerName directive. I'll locate ServerName in the httpd.conf file, uncomment the line, and insert the server name, as follows: ServerName www.example.com Next, we'll change the ServerAdmin directive, which defines the e-mail address to which Apache sends alerts. Sometimes this e-mail address appears on pages that the server generates, such as 404 page errors. To modify this directive, make an edit similar to: ServerAdmin example@example.com For all you PHP lovers out there, here are the directives for setting up PHP4 in the Apache configuration file. This assumes that PHP4 is compiled into Apache and is not a dynamic shared object (DSO), because we're not using the LoadModule directive to load the module into Apache. <IfModule mod_php4.c> AddType application/x-httpd-php .php .php4 .phtml AddType application/x-httpd-php-source .phps </IfModule> The above directive is a conditional test to determine if the module name is compiled into Apache or has been dynamically loaded. This test can be of two types: if or if not. The module is loaded into Apache either compiled or loaded as a DSO. Here is an example: <IfModule module_name> </IfModule> or <IfModule !module_name> </IfModule> A good starting point Our example Apache install should point you in the right direction for your own configurations. The best place I have found for documentation is Apache's Web site, which provides tons of information on configuring directives and other items, such as virtual hosts.
Copyright © 2009 CBS Interactive, a CBS Company. All Rights Reserved. |