Thursday, 20 April 2017

Install Apache WebServer on Linux

Since Apache is free, it's one of the most popular web servers to install. It also has several features that make it useful for many different types of websites.  
The Goal of this server is to provide secure, efficient and extensible way by which it provides all HTTP Standards & Services.
Get the facts on how to install Apache on a Linux system with this overview. 

 DOWNLOAD APACHE

I recommend downloading the latest stable release. The best place to get Apache is from the Apache HTTPServer download site. Download the source files appropriate to your system. Binary releases for some operating systems are available as well.
Download the required version of tar file – either httpd 2.2 or httpd 2.4 versions which are currently available in the Apache site.
Let’s download httpd-2.2.32.tar.gz in local drive, login as root or administrative account.

EXTRACT THE APACHE FILES

Once you've downloaded the files you need to uncompress them:

[root@middleware jboss]# tar -zxvf httpd-2.2.32.tar.gz

This creates a new directory under the current directory with the source files.

[root@middleware jboss]# cd  httpd-2.2.32

CONFIGURING YOUR SERVER FOR APACHE

Once you have the files, you need to tell your machine where to find everything by configuring the source files. The easiest way is to accept all the defaults and just type:

[root@middleware httpd-2.2.32]#./configure

Of course, most people don't want to accept just the default choices. The most important option is the --prefix=PREFIX option. This specifies the directory where the Apache files will be installed.

[root@middleware httpd-2.2.32]# ./configure  --prefix=/logicial/jboss/apache

You can also set specific environment variables and modules. Some of the modules I like to have installed include:
  • mod_alias - to map different parts of the URL tree
  • mod_include - to parse Server Side Includes
  • mod_mime - to associate file extensions with its MIME-type
  • mod_rewrite - to rewrite URLs on the fly
  • mod_speling (sic) - to help your readers who might misspell URLs
  • mod_ssl - to allow for strong cryptography using SSL
  • mod_userdir - to allow system users to have their own web page directories


Please keep in mind that these aren't all the modules I might install on a given system. Read the details about the modules to determine which ones you need.

BUILD APACHE

As with any source installation, you'll then need to build the installation:

[root@middleware httpd-2.2.32]# make
[root@middleware httpd-2.2.32]# make install

This creates/build a http conf, bin and lib & etc directories   of apache.

[root@middleware jboss]# cd apache/
[root@middleware apache]# ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  lib  logs  man  manual 

CUSTOMIZE APACHE

Assuming that there were no problems, you are ready to customize your Apache configuration. This really just amounts to editing the httpd.conf file. This file is located in the PREFIX/conf directory.  

vi PREFIX/conf/httpd.conf
vi /logicial/jboss/apache/conf/ httpd.conf

Follow the instructions in this file to edit your configuration the way you want it. More help is available on the Apache website. I have modified below parameters.

  • Listen 0.0.0.0:80
  • ServerName middleware.tech.com:80
  • User jbossas
  • Group jbossas

TEST YOUR APACHE SERVER

Start the web server
 [jbossas@middleware bin]$ /logicial/jboss/apache/bin/apachectl start


Open a web browser on the same machine and type http://middleware.tech.com:80 in the address box. You should see a page It works! .  as it means your server is installed correctly.



Stop the web server :

 [jbossas@middleware bin]$ /logicial/jboss/apache/bin/apachectl stop

No comments: