|
Configuring Apache Web Server
The main Apache configuration file is at
/etc/httpd.conf file:
-
If you install the Apache Web server via rpm command,
the httpd.conf configuration is stored at /etc/httpd/conf/httpd.conf
-
If you install the Apache Web server via source code,
the httpd.conf configuration is stored at /usr/local/apache2/conf/httpd.conf
Most of the details are specified using
compound directives.The format of the configuration file (httpd.conf) is as
follow:
Syntax:
|
<
[compound directive name] [agrument value]
>
option 1 argument value
option 1 argument value
.
.
< / [compound
directives name> |
Example:
<Directory "/var/www/html/member">
AuthType Basic
AuthName "Member Access Directory"
AuthUserFile /etc/httpd/.htpasswd
Require user basic [username,username]
</Directory> |
Explanation:
|
Syntax |
Description |
|
<Directory "/var/www/html/member"> |
This is one of the Directory directives in httpd.conf |
|
AuthType Basic |
Option is AuthType,
and Basic is the argumen value. |
Important section in Apache Configuration
File (httpd.conf)
There are 3 Major Sections
|
Sections |
Functions |
| Global Environment |
This is overall setting for apache,
including PID, modules,process that tells how CentOS Operating
System interact with Apache Web Server. |
| Server Section |
This is the subset of the Global
Enviroment setting, where the changes are only affect on the sub
processes such specifying web server name, access control for the
web directories. |
| Virtual Hosts |
This section enable multiple virtual
hosts/ domain under 1 physcal web server. |
Server Root
-
Server Root is the base configuration directory of the
Apache Web Server.
-
The server root for RPM packages is stored at /etc/httpd.
-
The server root for source code packages is stored at /usr/local/apache2.
Document Root
-
Document Root is the top-level directory that documents
to be provided to the client,
-
The document location is specified using the
DocumentRoot directive.
-
If you install the Apache Web server via rpm command
is at /var/www/html
-
If you install the Apache Web server via source code,
is at /usr/local/apache2/htdocs
| DocumentRoot /var/www/html |
Directory Index
-
The directory index is the default file that is
displayed when the browser is accessing. For example when a user
accessing 1a-centosserver.com he/she type in
http://www.1a-centosserver.com
-
The directory index is specified using DirectoryIndex
section.
-
One of more file can be specified for directory index
| DirectoryIndex index.htm index.php |
|