Apache http server in detail – 1

To verify httpd installed or not

rpm -qa httpd
(will display the package details if available)
 ex: httpd-2.2.15-29.el6_4.x86_64

Default Paths

/usr/sbin/httpd         command path
/etc/httpd              httpd root path
/etc/httpd/conf         Main config path
/etc/httpd/conf.d       Additional config path
/etc/httpd/logs         Link pointed to httpd log & error log

 Default log files of Apache Webserver

access_log           All access details
error_log            All Error Details

To re-load the config/modules

service httpd reload

To start the httpd service

service httpd start

To stop the httpd service

service httpd stop

To restart the httpd service

service httpd restart

To check the status of the service

service httpd status

Default Declarations used in the configuration file

ServerRoot                Default Root location of httpd
PidFile                   id of the initial httpd server;Because apache will create by default 
                          additional child process to handle traffic
DocumentRoot              File System Root Directory
  •  All paths mentioned in the config file will be calculated from ServerRoot path (i.e) Relative path
  • Default error log will be calculated from the server root directory. If one wants the error log to be moved to another place, create log directory as a symbolic link to another required folder. (Ex /var/log/httpd/logs)

Number of Server instances needs to be started can be set up in the below section.

<IfModule prefork.c>
     StartServers       8
     MinSpareServers    5
     MaxSpareServers   20
     ServerLimit      256
     MaxClients       256
     MaxRequestsPerChild  4000
</IfModule>

# StartServers: &nbsp;&nbsp; &nbsp;     number of server processes to start
# MinSpareServers:&nbsp;&nbsp; &nbsp;   minimum number of server processes which are kept spare
# MaxSpareServers: &nbsp;&nbsp;    maximum number of server processes which are kept spare
# ServerLimit: &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;    maximum value for MaxClients for the lifetime of the server
# MaxClients: &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;   maximum number of server processes allowed to start
# MaxRequestsPerChild:   maximum number of requests a server process serves

 Directives

  • Directory tag                                 –    can be used to apply settings for particular directory.
  • DirectoryMatch tag                      –    Same as Directory tag but we can use patterns.(i.e) setting rules for multiple directories (ex)
    <DirectoryMatch "^/www/(.+/)?[0-9]{3}">

    would match directories in /www/ that consisted of three numbers.

  • Options FollowSymLinks                 –    Webpages under this directory can point to any files under / directory via symbolic link. (i.e) outside of www directoy
  • AllowOverride None                          –    If set that partiular directory configuration can be overridden via .htaccess file
  • Order allow deny / deny allow        –    The meaning is if we mentioned allow deny then first allow will be taken, then deny will be taken
    if we mentioned deny allow then first deny will be taken then allow will be taken
    What is the cause of this? For example if we give like below

    Order deny allow
    allow from all
    deny from 192.168.101.100

    the expectation is to deny only from 192.168.101.100. But it will allow all people. Because we gave deny at first, allow later. So allow will over write deny order

  • Options Indexes                                   –    respond with directory listing if the index file not available. -Indexes (not allowed)  ,+Indexes (allowed)
  • Files Directive                                       –    similiar like Directory Directive; the difference is files directive is at file level where Directory directive is at directory level
  • FilesMatch directive                             –    similar like DirectoryMatch but for files
  • Location directive                                 –    similar like Files,Directory directives; but based on url config will be applied
    (ex)

    <Location /server-info>
    SetHandler server-info
    Order deny,allow
    Deny from all
    Allow from 192.168.227.1
    </Location>

Add a Comment

Your email address will not be published. Required fields are marked *