Apache configuration httpd.conf

3 main sections of httpd.conf
---------------------------------------

Main server configuration ( host-specific server directives)

Global environment ( the location of configuration files )

Virtual hosts (Server values specific to virtual hosts)


Global environment

ServerType ( run under inetd daemon or standalone service)
ServerRoot ( identifies server root , for security resons you need to ensure that root has exclusive write access to the server root directory tree and its contents and ordinary users cant make modifications )

Timeout 300 (default is 300 ie 5mins) ( sets time period for which apache waits during certain operations are performed before it sends or recieves a timeout signal )

StartServers ( number of services you want to run on startup)

Main server configuration

it contains directives for main server. the values of these directives are also used as default values for virtual hosts unless virtual hosts section of the file specifes diffrent values

it contains configrations related to

PortNumber
User and Group
ServerAdmin email@address.com ( mails if any notifications of server problems to this id)
ServerName www.validhostname.com:80 (address to which sites clients will connect, so give valid DNS name.)
DocumentRoot "/var/www/html" (content will be in this directory we can use symbolic links if space is less)
DirectoryIndex
ErrorLog
Alias
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

It is important to keep all the CGI scripts and executable files in single direcotry "cgi-bin" to avoid security risks
or if you want to give access to some executables then keep them in another directory.Also keep cgi-bin directory
outside /var/www/html
create different CGI direcotries for diffrent virtualhosts we can do it by setting User and Group

User apache
Group apache

when apache starts or get initiated it starts as root to configure itself but later it forks into child and run as
specified user and group as running as root causes security risks.

ps -aux | grep httpd

(display httpd processes currently running )

Listen 80 ( portnumber to listen to default is 80)

if you want to change port chage port higher than 1023 as below 1024 are reserverd for root's use

most commonly used options for httpd are
------------------------------------------------------

-d serverroot (sets the location of the server root overrieds ServerRoot in httpd.conf)
-f config ( carryout commands in configurations at startup)

-h display summary of possible commands
-L provides directive list and possible argeuments and locations where each directive is valid
-t run syntax tests on configuration files returns 0 if acceptable
-x instructs httpd to run in single-process mode genrally used for internal debugging.
-s verify the virtual host configuration

Virtual hosts

it enables to setup virtual host containers to enable multiple-server capability
without vritual hosting you need to run two seperate web servers listening on diffrent IP addresses, and
have a unique network interface bound to each address.
Virtual hosting enables you to host both sites on one computer with the same IP address.

No comments: