Apache Installation in Linux
·
The Apache HTTP Server, commonly referred to
as Apache, is a web server software 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.
·
Typically Apache
is run on a Unix-like operating system, and was developed for use on Linux.
·
Runs on Windows NT/9x, Netware 5.x and above,
OS/2, and most versions of Unix, as well as several other operating systems.
·
Can be customised by writing “modules” using the
Apache module API
·
Since April 1996
Apache has been the most popular HTTP server software in use. As of December
2012 Apache was estimated to
serve 63.7% of all active websites and 58.49% of the top servers across all domains.
Prerequisites
·
Before going to start installation of new apache
we need to remove completely the older httpd, if exists.
·
Run this
command if you installed apache with RPM or through the automatic option during
the Fedora/Red Hat OS installation.
# yum remove httpd
·
Check whether httpd list in system services
# chkconfig --list
·
Turn off httpd service
# chkconfig --levels 235 httpd
off
·
To find packages that are installed try
# rpm -qa httpd
or
# rpm -qa *apache* { note
"rpm -qa" lists all installed packages }
·
Remove httpd
# rpm -e --noscripts httpd
·
If you compiled apache on your own. If you did a
manual install then just delete /usr/local/apache (or wherever it is
installed).
# rm -rf /usr/local/apache2
·
Create a directory for where we need to
configure the Apache
# mkdir -p /lamp/apache
·
Dependencies for Apache to work properly
# yum install gcc gcc-c++
# yum install libxml2-devel
# yum install openssl-devel
# yum install ncurses-devel
# yum install make
# yum install
cmake
# yum install
automake
# yum install
openssl
#
yum install bison
รจ apr/apr-util -
·
apr and apr-util are bundled with the Apache httpd source
releases, and will be used without any problems in almost all circumstances.
However, if apr or apr-util, versions 1.0 or 1.1, are installed on your system,
you must either upgrade your apr/apr-util installations to higher(1.2 or
above), or have httpd use separate builds. To use the bundled apr/apr-util
sources for this purpose you must install them manually:
Download
·
The Apache HTTP Server can be downloaded from
the Apache HTTP Server download site.
# wget
http://downloads/httpd-2.2.15.tar.gz
Extract
·
Extracting the source from the Apache HTTPD
tarball,
# tar xvzf httpd-2.2.15.tar.gz
·
This will create a new directory under the
current directory containing the source code for the distribution. You should cd
into that directory before proceeding with compiling the server.
Configuring the source tree
·
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. Another commonly used option --enable-so turns on the DSO
support. More fine-tuned control of the location of files is possible with
additional configure options.
SSL support
·
To support secure connections, you need to
specify --enable-ssl option when you run ./configure. In addition
to that, you will also have to configure your httpd.conf file later.
Configuration
# mkdir –p /lamp/apache
# cd httpd-2.2.15
# ./configure –prefix=/lamp/apache
–enable-so –enable-ssl=shared
--enable-cache=shared
–enable-disk-cache=shared
--enable-rewrite=shared
·
When configure is run it will take several minutes to test for the
availability of features on your system and build Makefiles which will later be
used to compile the server.
·
If you are upgrading from older Apache version, you may want to
copy config.nice from the directory to which the previous version was unpacked
(if available) to where you unpacked the new Apache tarball file. Run
./config.niceinstead of ./configure. This way all the previously used configure
options will be applied to the new installation effortlessly.
Build
·
Now you can build the various parts which form
the Apache package by simply running the command:
# make
Install
·
Now it's time to install the package under the
configured installation PREFIX (see --prefix option above) by running:
# make
install
Post installations
#ln
–s /lamp/apache/bin/apachectl
/etc/init.d/webserver
#
service webserver start (to start the service)
#
service webserver stop (to stop the service)
For automatic start-up
#
chmod 755 /etc/init.d/webserver
#
chkconfig --add webserver
# chkconfig --level 35 webserver on
To check
# sevice apache start
#
netstat –ntulp | grep 80
#
elinks 192.168.1.203
OR
Check in the browser
· Restart apache service and check in browser by typing
our ip 192.168.1.203 it shows,
IT WORKS!
Controlling Apache
·
/etc/httpd/conf/httpd.conf The
configuration file for the Apache HTTP server.
·
.htaccess File used to control Apache's
behaviour on a per-directory basis.
·
/etc/init.d/httpd Script used to control
the httpd process - start, stop, restart, reload, status.
·
/var/log/httpd/ Contains the Apache logs
- error.log, access.log
Apache content
·
/lamp/apache/htdocs/ The “DocumentRoot” -
all websites are served from here by default.
·
$home/public html/ User‘s directory for
serving webpages.
·
index.html “DirectoryIndex” that is used
by default when a request specifies a directory.