Thursday 14 December 2017

Apache 2.4.x installation in Linux


Installation of apache in linux is bit different than windows. You have to install few dependencies first and then you have to compile the source code of apache. I am sharing step by step information of installing apache 2.4.x in Linux.

Download apache 

If you are on internet enabled linux server and wget utility is installed then you can download using below command


(if wget is not there then you can install it using $yum install wget)

If you don't have internet enabled Linux machine then you can first down load in your local machine (http://www-us.apache.org/dist//httpd/httpd-2.4.29.tar.gz) and then transfer using some ftp/ssh client like filezilla.

Download dependencies 

Similarly use wget or filezilla to transfer below utilities 



Installation

Now unzip & untar downloaded apache and both utilities using below commands

Suppose you have copied all above inside /opt/ directory 

Go inside directory (if you are not there)
$ cd /opt

unzip & untar apache

$gunzip httpd-2.4.29.tar.gz  (If gunzip not working then install it using $yum install gunzip)
$tar -xvf httpd-2.4.29.tar

it will create httpd-2.4.29 directory inside /opt, that means apache source files rctracted inside /opt/httpd-2.4.29 now

unzip and untar utilitities 

$tar -xvf apr-1.6.3.tar

$tar -xvf apr-util-1.6.1.tar

Now you will have apr-1.6.3 & apr-util-1.6.1 directory in side /opt
copy both directories inside /opt/httpd-2.4.29/srclib

$cp -r /opt/ apr-1.6.3 /opt/httpd-2.4.29/srclib
$cp -r /opt/apr-util-1.6.1 /opt/httpd-2.4.29/srclib

Inside /opt/httpd-2.4.29/srclib, rename both folders as below

$ mv apr-1.6.2 apr
$ mv apr-util-1.6.0.tar apr-util

Now inside /opt/httpd-2.4.29/srclib run below commands to install dependencies

$yum install apr-util-devel
$yum install apr-devel
$yum install pcre-devel

After successfully installation of above utilities

Go inside base directory

$cd /opt/httpd-2.4.29

Create a directory for apache 

$mkdir /opt/httpd-2.4.29/apache2.4

Now to install apache with enabling ssl run below command 

$./configure --prefix=/opt/httpd-2.4.29/apache2.4 --enable-mods-shared="all" --enable-so --enable-ssl 

To install with enabling ssl modules run below command

$./configure --prefix=/opt/httpd-2.4.29/apache2.4

It will take some some and at last make it's successful and not land up with any error

Now run below two commands

$make
$make install

bingo!! you are done with installation

To start/stop apache 

Go inside /opt/httpd-2.4.29/apache2.4/bin and run below commands

To start 
./apachectl -k start

To stop
./apachectl -k stop

To test just hit server i.p 
http://localhost, you will get a page with message "It Works!" 

Other Important Considerations - 

There are few important configuration files of apache but main configuration file which calls other configuration files and modules if httpd.conf and you will find it inside /opt/httpd-2.4.29/apache2.4/conf, by default apache use 80 port and only root have privileged to start services on port 80 (As in linux only root have privileged to start process on all ports <= 1024). so either you can start apache process from root user otherwise you have change port inside httpd.conf file (which should be any port not in use by any other process in your server and should be > 1024) to start from normal user. Generic practice is to use 8080

No comments:

Post a Comment