Tuesday, 30 July 2013

Changing settings

Apache behaves according to commands, called directives, in the configuration file (which is a plain text file). You can change some of Apache’s behavior by editing the configuration file and restarting Apache so that it reads the new directives.

In most cases, the default settings in the configuration file allow Apache to start and run on your system. However, you might need to change the settings in some cases, such as the following:

✦ Installing PHP: If you install PHP, you need to configure Apache to recognize PHP programs. How to change the Apache configuration for PHP is described in Chapter 3 of thisBlog.

✦ Changing your Document Root: Apache looks for web page files in a specific directory and its subdirectories, called your Document Root. You can change the location of your Document Root. Read the next section for instructions.

✦ Changing the port on which Apache listens: By default, Apache listens for file requests on port 80. You can configure Apache to listen on a different port. See the upcoming “Changing the port number” section for details on how to do that.

To change any settings, edit the httpd.conf file using a text editor. On Windows, you can access this file through the menu at Start➪Programs➪Apache HTTPD Server➪Configure Apache Server➪Edit the Apache httpd.conf File. When you click this menu item, the httpd.conf file opens in Notepad.

The httpd.conf file has comments (lines beginning with #) that describe the directives, but make sure you understand their functions before changing any. All directives are documented on the Apache website.

Here are some conventions to consider when you’re changing Apache settings:

✦ Filenames and paths: When adding or changing filenames and paths, use forward slashes, even when the directory is on Windows. Apache can figure it out.

✦ Path names: You don’t need to put path names in quotes, unless they include special characters.

✦ Special characters: A colon (:) is a special character; the underscore (_) and hyphen (-) are not.

For instance, to indicate a Windows directory, you would use something like the following:

“c:/temp/mydir” 

The settings don’t go into effect until Apache is restarted. Sometimes, using the restart command doesn’t work to change the settings. If the new settings don’t seem to be in effect, try stopping the server with stop and then starting it with start.

No comments:

Post a Comment