Apache 2

apache_software_foundation_logo_3074

 

The Apache HTTP Server, commonly referred to as Apache (/əˈpæ/ ə-pa-chee), is a web server software program notable for playing a key role in the initial growth of the World Wide Web.In 2009, it became the first web server software to surpass the 100 million website milestone. Apache has consistently been the most popular web server on the Internet since taking that spot from NCSA HTTPd back in 1996. Typically Apache is run on a Unix-like operating system,and was developed for use on Linux.

Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation. The application is available for a wide variety of operating systems, including UnixFreeBSDLinuxSolarisNovell NetWareOS XMicrosoft WindowsOS/2TPF, and eComStation. Released under the Apache License, Apache is open-source software.

Apache was originally based on NCSA HTTPd code. The NCSA code has since been removed from Apache, due to a rewrite.

Since April 1996 Apache has been the most popular HTTP server software in use. As of June 2013, Apache was estimated to serve 54.2% of all active websites and 53.3% of the top servers across all domains.

Apache HTTP Server
ASF-logo.svg
Original author(s) Robert McCool
Developer(s) Apache Software Foundation
Initial release 1995[1]
Stable release 2.4.6 (July 22, 2013; 7 days ago) [±]
Development status Active
Written in C[2]
Operating system Cross-platform
Available in English
Type Web server
License Apache License 2.0
Website httpd.apache.org

 

Installation of Apache2 in ubuntu

# apt-get install apache2

Config File Location

#etc/apacahe2/

 

# cd /etc/var/www/html

 

 

index.html (apache file)

Check in url type:localhost or your system ip ……getting Itworks default apache html (a working apache server)

apache test

Apache Directories and Main Configuration Files

The /etc/apache2 Directory

This directory contains all the configuration files for your Apache server. The top of most configuration files in this directory include details on its general purpose.

The basic functionality of the files are described in the next section.

/etc/apache2/apache2.conf File

This is the main configuration file that ultimately controls how Apache functions. While it is possible to completely configure your sites and modules directly in this file, instead it is recommended to use smaller individual files for each of your sites and modules for simplicity. This is made possible by the “Include” directive to insert other files into the apache2.conf at runtime. Some of the values of interest in here are:

  • Timeout
Length of time in seconds that Apache attempts to fulfill a request. Default: 300
  • KeepAlive
Define if persistent connections is allowed, which allows more than one request per connection. Default: On
  • MaxKeepAliveRequests
Define the maximum number of requests allowed for each KeepAlive persistent connection. Default: 100
  • KeepAliveTimeout
Define the number of seconds to wait for another request before ending the KeepAlive persistent connection. Default: 5
  • MPM Configuration
Debian and Ubuntu have different Apache packages that are optimized for different situations. Each package is a different flavor of MPM (multi-processing module) and settings for each are defined near the end of this file. The packages available are apache2-mpm-prefork, apache2-mpm-worker, and apache2-mpm-event, with apache2-mpm-worker being the default. This is the default threaded implementation of Apache and is recommended for high-traffic sites due to its speed and smaller memory footprint.

To check which MPM configuration (and modules) exist, run the following:

sudo apache2 -l

The enabled modules are listed, ending with .c. In this case, the worker module is enabled:

Compiled in modules:
 core.c
 mod_log_config.c
 mod_logio.c
 mod_version.c
 worker.c
 http_core.c
 mod_so.c

Virtual Hosts

Virtual hosts define each site so that Apache knows what it should do when it receives a request.

/etc/apache2/sites-available/default

  • Defines what Apache should do when it gets a request that matches no other virtual hosts.
  • If you only expect to have one site on your DreamComputer instance, you could use this file and no others if you prefer.
  • For those with multiple sites, this can be used to instruct the visitor that they may have done something wrong, or redirect them to another site.

/etc/apache2/sites-available/YOURSITEHERE

  • For each site you wish to configure, we recommended you name a file similar to your site name in the /etc/apache2/sites-available/ directory.
  • There are several example virtual hosts available on the wiki.apache.org Example Vhosts page but you can view a basic one for listening on port 80 (http) with custom logging here:
<VirtualHost *:80>
   ServerName ami.net
   ServerAlias www.ami.net
   DocumentRoot /var/www/html/ami.net

   CustomLog /var/log/apache/www.foo.com-access.log combined
   ErrorLog /var/log/apache/www.foo.com-error.log
</VirtualHost>
  • Alternatively, if you wish to specify the ip instead of “*” you can use the following command replacing 1.1.1.1 with your real ip address:
<VirtualHost 1.1.1.1:80>

Managing Virtual Host files

When you have your sites virtual host file setup, you can enable/disable it by entering the following commands:

sudo a2ensite
Provides a list of sites files that you can enable.
sudo a2dissite
Provides a list of sites files you can disable.
service apache2 reload
Reloads apache to make the change live after you enable or disable a site.

These commands create a symlink for your sites file from /etc/apache2/sites-enabled to its corresponding file in /etc/apache2/sites-available.

Modules

Modules can be enabled or disabled by the following commands:

sudo a2enmod
sudo a2dismod
  • When you run the command, it displays a list of modules available to enable or disable.
  • After you enable or disable a site, reload Apache to make the change live by using the following command:
service apache2 reload

Removing  apache2

sudo apt-get remove --purge apache2 apache2-utils

 

See also

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s