Apache Web Server One of many projects undertaken by the Apache Foundation It is most popular HTTP server. Free Free for commercial and private use Source code is available (open-source) Portable Available for variety of platforms, including Windows Primary target has been traditionally Linux Scalable Hardware requirements are very low
Apache Usage Apache is used to serve static and dynamic content Static content = traditional HTML pages Dynamic elements refer to scripts and programs running on server side Apache offers secure (encrypted) connections over SSL using OpenSSL libraries Apache is a crucial element of the LAMP infrastructure LAMP = Linux + Apache + MySQL + PHP/Perl/Python All LAMP technologies are free and open source The developmental nature of Linux OS caters to dynamic content developers
Apache Versions Apache development is done currently in three major release versions (probably new release also available) 1.3.x Reliable and proven Many websites currently run this version Is still around as much existing software depends on this version 2.0.x Better support for non-unix/linux platforms IPv6 support Simplified configuration 2.2.x Large file (>2GB) support This is the version we will be using For more technical details please see the Apache Foundation website http://apache.org
Installation of Apache Web Server Follow the Instruction from the Installation manual. First you have to have Zenit account provided by your Teacher with ports for each account. Login to your Zenit Account and then follow the instructions (provided to you) how to install and configure Apache. Probably it takes little bit time to finish installation.
Apache Server Once Installation done you will see a directory $HOME/httpd is created where you will find all configuration Directories and files. You can change the name of htttpd directory if you want too. Apache can read from up to four configuration files. a) httpd.conf b) Access.conf c) Srm.conf d) Mime.types httpd.conf file is the main server configuration file, usually it is recommended that you keep all of your configuration directives in httpd.conf file. Please read httpd.conf file carefully. You can find this file by typing the command in httpd directory : vi conf/httpd.conf
Apache configuration in detail Administrators control Apache server through directives in httpd.conf httpd.conf is read only once when the server is started Some Apache version have additional configuration files Directives in httpd.conf can be augmented through directory-specific configuration files (AccessFile) These files are controlled by directory owners Apache reads them every time a directory is accessed Directives have a different scope/context Server: Virtual Host: Directory: affecting a specific directory.htaccess: allowable only in.htaccess files affecting the entire server Affecting a specific IP, port, or domain in case a single server represents multiple hosts Some directives can appear in more than one scope Directives can be single-line or block containers
Important Server Directives ServerRoot ServerRoot /home/username/httpd Apache installation directory where you will save all Perl-cgi files. DocumentRoot DocumentRoot /home/username/httpd/htdocs Topmost directory for files served by Apache where you will save all of your HTML files. By default all requests are take from this directory. Listen Port at which Apache listens to requests Default port is 80 Appears also in Virtual Host context User and Group Defines the privileges of the server process Should be limited in access ServerAdmin Email address of server administrator Included in various status and error pages Can appear in Virtual Host context Alias Virtual directory Can appear in Virtual Host context
Directory Container Directive Directory container is a block structure that contains other directives Directory containers affect specific directories Subdirectories inherit these settings unless their own directory container will override them Typically directory containers are used for the following Options such as indexing (displaying of directory listings) Customized behaviour Server-Side Includes, error pages etc Access control by user/password and IP An AccessFile (.htaccess), if present in directory, will take precedence over the directory container This must be explicitly enabled in the container AccessFiles affect subdirectories the same as containers Overriding is allowed for all settings or selected ones
Apache Logs Logs document ongoing activities of the server What resources were requested and when What hosts accessed the server Bandwidth usage Access to restricted content Server errors Logging is highly customizable By default, Apache maintains two log files ServerRoot/logs/access_log ServerRoot/logs/error_log It is the responsibility of the administrator to review log information on an ongoing basis and rotate the logs
access_log file This log file documents each request to the server By default, the following is recorded The IP address of the client, for example: 142.204.1.2 ID of the user that performed the request, for example: bob Date and time, for example: [12/Mar/2007:12:32:59-0400] Request method, requested resource and HTTP version, for example: "GET /images/610445-710564.gif HTTP/1.1" Response status code, for example: 200 Size of the response not including the headers, for example: 6344 Referrer of the request, for example: /index.html Browser signature, for example: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Information not available is indicated by a hyphen (-)
Custom access logs Apache allows customization of access logging using two directives in httpd.conf: 1. LogFormat Defines what is recorded in the log, in what format and which order 2. CustomLog Defines the name and location of the log file Ties a physical file above to a LogFormat Nothing stands in a way of having multiple log files Multiple logs are easier to understand than one big log Presumably each log file would record something else Extensive logging takes up disk space and decreases the efficiency of the web server
Perl-CGI in Practice Perl Scalars Perl Array Perl Hashes Run program in cgi-bin directory from any browser.