Você está na página 1de 7

Activity 3: Apache Installation and Configuration

Name: ___________________________ Date: _____________

Objectives:
• Learn how to install Apache Web Server from a tarball (binary package)
• Familiarize the students on how web server works
• Learn how to configure Apache web server according to a given specification
• Familiarize on how to build a high profile web server

Concepts

How Web Server Works

The diagram shows that your browser formed a connection to a Web server, requested a page and
received it.

The browser broke the URL into three parts:


1. The protocol ("http")
2. The server name ("hei.donbosco.net")
3. The file name ("demo.html")

• The browser communicated with a name server to translate the server name "hei.donbosco.net" into
an IP Address, which it uses to connect to the server machine.
• The browser then formed a connection to the server at that IP address on port 80. Following the
HTTP protocol, the browser sent a GET request to the server, asking for the file
"http://hei.donbosco.net/demo.htm."
• The server then sent the HTML text for the Web page to the browser.
• The browser read the HTML tags and formatted the page onto your screen.

Archiving,Compressing and Decompressing Using tar

A tar ball is usually an archive file, similar to a zip file on Windows. Tar balls come in files that
end in:
.tar
.tar.gz
.tgz

The syntax for the tar command is:


tar [options] archive-filename file-or-directory-to-archive

The commonly used options are:


-c
creates an archive file
-x
Extract the archive
-f
creates the archive with given filename
-t
displays or lists files in archive file
-u
archives and adds to an existing archive file
-v
displays verbose information
-A
Concatenates the archive files
-C
change to directory
Note:
tar has no compression and decompression capabilities of its own. tar is commonly used in
combination with an external compression utility.

Options For Compression Utility


-j
bzip2
-Z
for compress
-z
for gzip

Example: Creating a tarball for several files


sysadmin@AMD64~$> touch example1.txt example2.txt example3.txt example4.txt
sysadmin@AMD64~$> ls
example1.txt example2.txt example3.txt example4.txt

sysadmin@AMD64~$> tar -cvf myfiles.tar example1.txt example2.txt example3.txt example4.txt


sysadmin@AMD64~$> ls
example1.txt example2.txt example3.txt example4.txt myfiles.tar

Example: To view the contents of an archive file


sysadmin@AMD64~$> tar -tvf myfiles.tar
example1.txt example2.txt example3.txt example4.txt

Example: To extract an archive file


sysadmin@AMD64~$> mkdir extracts
sysadmin@AMD64~$> ls
example1.txt example2.txt example3.txt example4.txt myfiles.tar extracts

sysadmin@AMD64~$> tar -xvf myfiles -C extracts/


sysadmin@AMD64~$> ls extracts
example1.txt example2.txt example3.txt example4.txt

Example: To extract a gzip file


sysadmin@AMD64~$> mkdir mydocs
sysadmin@AMD64~$> ls
example1.txt example2.txt example3.txt example4.txt myfiles.tar extracts mydocs

sysadmin@AMD64~$> tar -cvzf files.tar.gz *.txt


sysadmin@AMD64~$> ls
example1.txt example2.txt example3.txt example4.txt myfiles.tar extracts mydocs files.tar.gz
sysadmin@AMD64~$> tar -xvzf files.tar.gz -C mydocs
sysadmin@AMD64~$> ls mydocs
<all files with .txt extension should be here!>

Compiling and Installing Software Application

The installation procedure that comes in a .tar.gz and tar.bz2 packages isn't always the same, but
usually the necessary steps are as follows:

• tar -xvzf package.tar.gz (or tar -xvjf package.tar.bz2)


• cd to the package directory
• ./configure
• make
• make install

These simple commands are used to unpack, configure, and install the software package.
<Step 1> Unpacking
As discussed in the earlier part of this activity paper, having a .tar, .tar.gz / .tgz or .bz2 means that the
files are archive/compressed files or known as a tar ball.

<Step 2> Configuring


After unpacking the installation files, it is now time to configure the package. You need to read
the README and INSTALL files included in the package before running the configure script.

When you run the configure script, you don't actually compile anything yet, configure just
checks your system and assign values for system-dependent variables. These values are used for
generating a Makefile. The Makefile in turn is used for generating the actual binary.

When you run the configure script, you will see a bunch of weird messages scrolling on your screen.
This is normal. If configure finds an error, it complains about it and exits. However, if everything
works, it exits and shuts up.

You run the script with this command:


sysadmin@AMD64~$> ./configure

<Step 3> Building

To build the binary, the executable program, from the source code is accomplished by make
command.
sysadmin@AMD64~$> make

Note that the make needs the Makefile for building the program. This is why it's important to
run the configure script successfully.

<Step 4> Installing

To actually install the program with the make install command:


sysadmin@AMD64~$> make install

<Step 5> Cleaning Up The Mess

To save some disk space, you have to delete the files you do not need. When you ran make it
created all sorts of files that needed during the build process that will become useless now and are just
taking up space.

You will be executing the command make clean


sysadmin@AMD64~$> make clean

Make sure you keep your Makefile. It's needed if you later decided to uninstall the program.
Apache Web Server

Apache, otherwise known as Apache HTTP Server, is an established standard in the online
distribution of website services, which gave the initial boost for the expansion of the World Wide Web.
It is an open-source web server platform, which guarantees the online availability of the majority of the
websites active today. The server is aimed at serving a great deal of widely popular modern web
platforms/operating systems such as Unix, Windows, Linux, Solaris, Novell NetWare, FreeBSD, Mac
OS X, Microsoft Windows, OS/2, etc.

There are two popular versions for the origin of the project's name. According to the more
widespread one - the web server's name was chosen out of respect for the Native American Indian
Apache tribe, well known for its resilience and military skills. The other version refers to the set of
patches attached to the codebase of NCSA HTTPd 1.3, which makes it "a patchy" server.

The Apache server has been developed by an open source community - Apache Software
Foundation, whose members are constantly adding new useful functionalities, with the sole purpose of
providing a secure and extensible server platform that ensures HTTP service delivery in accordance
with the current HTTP standards.

There is a great amount of modules created especially for the Apache server, which support
various scripts and allow dynamic content to be run on the server. Most of the modules come as part of
the Apache distribution, making the server boast a wide range of capabilities, such as support for CGI
(Common Gateway Interface), a standard protocol for communication between external application
software and a web server, and also SSI (Server Side Includes), a simple server-side scripting language.
Other Apache modules include: CGI scripts execution, user authentication, URL redirection,
anonymous user access, automatic directory listings, support for HTTP header metafiles, support for
loading modules, content negotiation, caching proxy abilities, server status display, user home
directories, etc. Users can choose to install those modules with the Apache server installation. If not,
they can install them later with the help of dynamic modules.

The Apache server has been the most popular web server on the Internet since April 1996. It is
by no means considered a platform criterion for the development and evaluation of other successful
web servers.

Procedures:

1. Download the latest Apache tarball. Latest version as of writing is 2.2.15 released(2010-03-06).
File: httpd-2.2.15.tar.gz
Location to download: /home/Dawat/donwloads
FTP server: ________________________
FTP username: _____________________
FTP password: _____________________

2. Decompress and untar the binary package you just have downloaded.
3. You need to install all of the basic software components necessary to compile your Apache
binary package. "build-essential" is required if you are trying to install a program which must
be compiled.

sysadmin@AMD64~> apt-get install build-essential

4. Configure the Apache source tree for your particular platform and requirements. This is done
using the configure script included in the directory of the distribution.

To configure the source tree using all the default options, simply type ./configure. To change
the default options,configure accepts a variety of variables and command line options.

The most important option is the location -- prefix where Apache is to be installed later,
because Apache has to be configured for this location to work correctly. More fine-tuned
control of the location of files is possible with additional configure options.

Also at this point, you can specify which features you want included in Apache by enabling and
disabling modules. Apache comes with a Base set of modules included by default. Other
modules are enabled using the - -enable-module option, where module is the name of the
module with the mod_ string removed and with any underscore converted to a dash. You can
also choose to compile modules as shared objects (DSOs) -- which can be loaded or unloaded at
runtime -- by using the option --enable-module=shared. Similarly, you can disable Base
modules with the --disable-module option. Be careful when using these options, since configure
cannot warn you if the module you specify does not exist; it will simply ignore the option.

In addition, it is sometimes necessary to provide the configure script with extra information
about the location of your compiler, libraries, or header files. This is done by passing either
environment variables or command line options to configure.

sysadmin@AMD64~> ./configure --prefix=/usr/local/apache2

The configure script explores your operating system and creates the Makefile for it so you can
execute the following to start the actual compilation process, copy files into the directory set by the –
prefix option and execute the apachectl script to start the Apache server.

5. Compile Apache by running make. This will compile the source code into executable.

6. Install Apache using the make install script. In this step, all binaries will be copied into the
install directory and sets up the modules.

7. Starting, Stopping and Restarting Apache. We now start/stop Apache using the apachectl script
found at the bin directory of your install directory.
sysadmin@AMD64~> /usr/local/apache2/bin/apachectl start

sysadmin@AMD64~> /usr/local/apache2/bin/apachectl stop

sysadmin@AMD64~> /usr/local/apache2/bin/apachectl restart

8. Start Apache on boot. You also need to configure your operating system to start Apache when
the computer boots.

sysadmin@AMD64~> cd /etc/rc3.d

sysadmin@AMD64~> ln -s /usr/local/bin/apachectl S85httpd

9. Testing the installation. To verify if the installation was successful, try to access the web server
using a browser as a client.

Você também pode gostar