Professional Documents
Culture Documents
APACHE
WEBSERVER
INSTALLATION
&CONFIGURATION
ASIM SALEEM
HASEEB AHMAD
DEPARTMENT OF ELECTRONCS ENGINEERING
Outline
Introduction to ubuntu
Introduction to Apache2
Installation of apache
Some Features
Activating the User's public_html Directory
Domain Mapping
Creating Virtual Directory
Objective
Our objective of this project is the installation of apache2 on Linux (ubuntu) and configures
it. We have tried to implement as more as possible functions of apache2 web server.
Introduction to UBUNTU
Ubuntu is a free, stable, and secure OS. Ubuntu comes at a tempting price and provides many
of the advantages of popular commercial operating systems such as Windows and OS X. But
it also has potential drawbacks — manual installation and possible compatibility issues.
However, in recent years, Linux has also become valuable on desktop and laptop computers,
making it an option for individuals and businesses. Ubuntu is generally known to be the most
widely used version of Linux available. Because the software is free to download and share,
it is difficult to track exact usage numbers.
Introduction to Apache2
Apache is a web server application that has a played a major role in the growth and
continuous development of the web. It is a free open-source solution, which backs up most
popular operating systems including Microsoft Windows, Linux, Unix, Mac OS X and
Solaris. Apache is the most widely installed server application on the web since 1996.
Historical Perspective
The first version of the Apache web server was created by Robert McCool, When McCool
left NCSA in mid-1994, the development of httpd stalled, leaving a lot of patches for
improvements circulating through e-mails. These patches were provided by a number of other
developers besides McCool: Brian Behlendorf, Roy Fielding, Rob Hartill, David Robinson,
Cliff Skolnick, Randy Terbush, Robert S. Thau, Andrew Wilson, Eric Hagberg, Frank Peters
and Nicolas Pioch.
According to the Apache Foundation, the name was chosen out of respect for the Native
American tribe of Apache (Indé), well-known for their endurance and their skills in warfare.
However, the original FAQ on the Apache Server project's website, from 1996 to 2001,
claimed that "The result after combining [the NCSA httpd patches] was a patchy server. The
first explanation was supported at an Apache Conference and in an interview in 2000 byBrian
Behlendorf, who said that the name connoted "Take no prisoners. Be kind of aggressive and
kick some ass". Behlendorf then contradicted this in a 2007 interview, stating that "The
Apache server isn't named in honor of Geronimo's tribe" but that so many revisions were sent
in that "the group called it 'a patchy Web server'". Both explanations are probably appropriate
though the pun explanation has fallen into disfavor.
Version 2 of the Apache server was a substantial re-write of much of the Apache 1.x code,
with a strong focus on further modularization and the development of a portability layer, the
Apache Portable Runtime. The Apache 2.x core has several major enhancements over
Apache 1.x. These include UNIX threading, better support for non-Unix platforms (such as
Microsoft Windows), a new Apache API, and Ipv6 support. The first alpha release of Apache
2 was in March 2000, with the first general availability release on April 6, 2002.
Apache Rocks
Unix Threading: Apache has the ability to run a hybrid multithreaded mode in Unix servers.
This process improves scalability for most configurations.
Multiprotocol Support: This features allows Apache to act as a platform for protocols other
than HTTP, enabling a machine to go far beyond the traditional web server.
Enhanced Support for Non-Unix Systems: Apache 2 is more stable and much faster on
other platforms such as Windows, which tends to perform better with Microsoft server
applications.
Filtering: The new filtering feature allows modules to be written as filters that can act on
streams of data sent to and from the server. For example, CGI scripts can be parsed for SSI
(server side include) directives by using the INCLUDES filter. The module filter enables
external programs to function in same manner that allows CGI programs to act as handlers.
Multilanguage Error Response: With Apache 2, SSI documents are used to send error
response messages to the web browser in various languages. These messages can be easily
customized by the system administer to get a consistent look and feel.
Easy Configuration: Most of the confusing, complex directives of the original Apache have
been simplified in version 2.0. The Server name directive gives the name of the server and
only the port number for redirection and virtual host recognition.
Unicode Support for Windows NT: On Windows NT, Apache 2.0 uses the native Unicode
for the encoding of all filenames. This enables the application to provide multi-language
support for all Windows NT systems including 2000 and XP.
Updated REL: Apache 2.0 is integrated with the Perl compatible Regular Expression
Library based on the powerful syntax of Perl version 5.
lunarpages is one of many providers who realize that Apache 2.0 is the server platform of the
future. With all the features mentioned above and others such as IPv6 (Internet Protocol
version Six) support and multi-user administration, Apache 2 has proven to be a reliable
workhorse more than able to meet the demand of today’s World Wide Web.
Uses
Apache is primarily used to serve static as well as dynamic Web pages on the World Wide
Web. Many web applications are designed expecting the environment and features that
Apache provides.
Apache is the web server component of the popular LAMP web server application stack,
alongside Linux, MySQL, and the PHP/Perl/Python (and now also Ruby) programming
languages.
Apache is redistributed as part of various proprietary software packages including the Oracle
Database or the IBM WebSphere application server. Mac OS X integrates Apache as its built-
in web server and as support for its WebObjects application server. It is also supported in
some way by Borland in the Kylix and Delphi development tools. Apache is included with
Novell NetWare 6.5, where it is the default web server. Apache is also included with many
Linux distributions.
Installation of Apache
System Requirements
Apache runs on just about any platform in use today, including Linux; FreeBSD; OpenBSD;
NetBSD; BSDI; Amiga OS 3.x; Mac OS X; SunOS; Solaris; IRIX; HPUX; Digital Unix;
UnixWare; AIX; SCO; ReliantUNIX; DGUX; OpenStep/Mach; DYNIX/ptx; BeOS; and
Windows.
Though apt-get is generally used to install binary packages, it also can build and install
source packages. One can further more ease the process of installing software by using
Synaptic.
apt-get depends on Debian packages repositories that can be configured in the file
/etc/apt/sources.list. A typical Debian stable sources.list would look something like this :
#Local Mirror
deb ftp://ftp.us.debian.org/debian/ stable main contrib non-free
deb-src ftp://ftp.us.debian.org/debian/ stable main contrib non-free
#Security Updates
deb ftp://ftp.us.debian.org/debian-security/ stable/updates main contrib non-
free
deb-src ftp://ftp.us.debian.org/debian-security/ stable/updates main contrib non-
free
Once the user has a sources.list adapted to his/her needs, the local list of packages needs to
be updated :
apt-get update
Some Features
Start Apache 2 Server
This command will restart the apache server. It is required when we stop the server due to
some reason and want to start it again.
# /etc/init.d/apache2 start
Similarly apache can be restarted or stopped by using the same commands with a little bit
change in itself.
# /etc/init.d/apache2 stop
Document Root
It is a directory (a folder) that is stored on host's servers and is designated for holding web
pages. When someone else looks at your web site, this is the location they will be accessing.
In order for a website to be accessible to visitors, it must be published to the correct directory,
the "document root."
We have installed apache2 web server and now we activate user public directory. We create a
directory (folder) called "public_html" in our home directory,
There are only two commands we need to enter to activate the User Directory feature, and
then one command to restart the apache server. The last command includes an absolute path,
so it doesn't matter where we execute it from. The first two "ln" commands assume we are in
the directory /etc/apache2/mods-enabled. What we need to do is create two symbolic links
(soft links, symlinks) in the stated directory pointing to the corresponding module in
/etc/apache2/mods-available (which is where they really live). So, if "$" is your prompt,
me@myhost$ cd /etc/apache2/mods-enabled
Open up a browser and type http://localhost/~asim, where "asim" is our username. Apache
should show the folders and files we have in our directory, or even display a web page if we
have an "index.html" file in there.
Saving files outside:
Files that can be downloaded from our web site can be saved outside the public_html folder.
It is necessary in case we want to allow downloading for registered users only. In such case
we should set the access right of the files to registered users and we should save the files
outside the public_html folder, so only registered users can access it.
If we are using linux server and our path to public_html folder is e.g.:
/usr/home/ username/public_html
/usr/home/username/
Domain Mapping
Def.
The Domain Mapping allows user to use a custom domain name instead of the standard
domain name.
Now we will map the domain of localhost.
First of all, open apache’s main configuration file, name /etc/apache2/apache2.conf. A
search for the word virtual brings us to the following line:
Include /etc/apache2/sites-enabled/[^.#]*
This mean that when starting apache, it will look for files in /etc/apache2/sites-enabled/.
We go there and see what is in.
$cd /etc/apache2/sites-enabled/
$ls -l
total 1
This only links to the file in directory /etc/apache2/sites-available/. We might wonder what
the point in doing such is. Well, this simply allows us, mainly when we are using our box as a
web server.
Now we want to to map the domain name dev.haseeb.com to our local machine, using the
code file in /home/myuser/public_html/haseeb.com/.
<VirtualHost dev.example.com>
ServerAdmin webmaster@localhost
#We want to be able to access the web site using www.dev.haseeb.com or
dev.haseeb.com
ServerAlias www.dev.haseeb.com
DocumentRoot /home/myuser/public_html/haseeb.com
Now, we specified a new host to apache but it is not yet linked to the repertory where apache
actually looks for virtual hosts. Let go to:
$cd /etc/apache2/sites-enabled/
and create a link to the file we just created:
$sudo ln -s /etc/apache2/sites-available/haseeb.com.conf
Now apache is almost ready to restart, but before doing so, we must inform our linux system
that dev.haseeb.com and www.dev.haseeb.com are not to be looked for on the net, but on the
local machine instead.
To do so, simply edit /etc/hosts and add the new host names at the end of the line beginning
by 127.0.0.1, which is localhost.
In the end, our file should look like:
Open our web browser and enter the following address dev.haseeb.com. It runs the same as
when we were using http://localhost
Creating Virtual Directory
A virtual directory offers a way to provide a consolidated view of user identity without
constructing an entire directory infrastructure.
It receives requests and directs them to the appropriate data sources. When the user data
comes back, the directory provides the data to the appropriate application as all the data had
been stored in one place. The feature to reach into native disparate repositories makes virtual
directory technology ideal for combining data stored in a distributed manner.
Now we made a virtual directory /asim for physical path
/home/asim/public_html/haseeb.com/test
We edit the asim file. Say we want to create virtual directory named asim with the folder
/home/asim/public_html/haseeb.com/test. Then we have to add the following lines in the asim file
<Directory /home/asim/public_html/example.com/test>
DirectoryIndex index.html
Options FollowSymLinks
AllowOverride None
order allow,deny
allow from all
</Directory>
Restart apache
References
http://www.linuxforums.org/forum/linux-tutorials-howtos-reference-material/64958-
how-install-software-linux.html
http://www.mybestratedwebhosting.com/best-web-hosting-tips/introduction-to-
apache-2.html
http://en.wikipedia.org/wiki/Apache2
http://www.techsoup.org/learningcenter/software/page7858.cfm
http://www.linuxforums.org/forum/linux-tutorials-howtos-reference-material/64958-
how-install-software-linux.html
http://forums.opensuse.org/applications/404662-how-start-stop-apache2.html
http://www.cyberciti.biz/faq/ubuntu-linux-start-restart-stop-apache-web-server/
http://kimbriggs.com/computers/computer-notes/linux-notes/apache2-public_html-
virtual-directories.file
http://techgurulive.com/2009/02/21/how-to-configure-virtual-hosting-using-apache-2-
on-ubuntu/
http://www.aitechsolutions.net/apacheredirect.html
http://tipsntricksbd.blogspot.com/2009/06/how-to-create-virtual-directory-in.html
http://ubuntuforums.org/showthread.php?t=28184
Books:
Apacheserver2bible by Mohammed j. Kabir