Linux Server How ToHow To Setup, Configure, Manage and Secure a Linux Server |
|
Home Which Linux Distribution? Linux Server Hardware Linux Server Security Linux Web Server - Apache Introduction to Apache2 Install Apache with Apt-get Install Apache From Source Compile Options Configuring Apache Linux DNS Server - Bind Linux DHCP Server - DHCPD Linux Mail Server - Sendmail LDP How To's About This Site |
Linux Server How To - Basic Apache2 ConfigurationConfiguring Apache2Configuring Apache2 is performed through a series of text configuration files and is as simple as editing these files with a text editor such as Vi or Pico and restarting the web server so that the changes take effect. The configuration files can be quite extensive and on many installations are broken into smaller files that control a specific aspect of the web server such as virtual hosts and ssl for example. So you may have a main configuration file, typically called httpd.conf or possibly apache2.conf and a series of smaller ancillary configuration files located in that directory or in a subdirectory which is generally called extra. These additonal configuration files are tied in so to speak with the main configuration file with an include statement that instructs Apache2 to include the contents of that file when loading its configuration. An example of this is shown below, where we can see the virtual hosts include file commented out by a #, which we would remove if we chose to include the virtual hosts configuration file in the Apache2 configuration of our Linux server.
The actual location of your Apache2 configuration files on your Linux server will vary slightly from distribution to distribution and will also be dependant on whether you chose to use the Apache2 that shipped with your Linux installation and if you used a package manager like apt-get or rpm or installed from source. If you compiled your install of Apache2 from source the configuration files will be found in a conf directory in the server root, so for example if you elected to install Apache2 in /usr/local/apache2 your configuration files will be found in /usr/local/apache2/conf. If your using an install of Apache2 that was installed when you installed your Linux server or through a package management system you will likely find your Apache2 configuration files in /etc, probably in a directory called /etc/httpd or /etc/apache2.
Change the Document RootThe document root is the folder on your Linux servers file system that contains the contents of the web page that you would like to display. The default document root is /usr/local/apache2/htdocs in our compiled install of Apache2 on our slackware Linux server and /var/www on our Ubuntu Linux server that had Apache2 installed using apt-get. You may wish to change the document root to something more accessible or convenient, like the home directory of your web designer for example. The document root is changed in the httpd.conf or apache2.conf configuration file. In the example snippets of this file below we have commented out the original lines and replaced them with new ones which are shown in bold. The first thing to change is the DocumentRoot directive.
Apache2 is configured in a very secure manner by default and will not display a web page from our web designers home directory without further information regarding how to treat the contents of this folder. The original configuration for the default document root is fine, we just need it to know what the new document root is.
|
| © 2009 www.linuxserverhowto.com |