Sunday 2 September 2018

Apache2 installation with source code

Step 1

Install dependencies that required for apache.
  1. gcc
  2. zlib-devel
Download the required packages
  1. httpd-2.2.31.tar.gz
  2. openssl-1.0.2g.tar.gz
  3. apr-1.5.2.tar.gz
  4. apr-util-1.5.4.tar.gz
Required modules from Link
  1. mod_jk.so
  2. mod_jk-1.2.31-httpd-2.2.x.so

Step 2

1. Install dependencies with yum

yum install gcc* zlib-devel* -y
 
2. Untar the packages in required directory.

mkdir /u01/apache

move packages to the apache directory and untar

tar –xzf httpd-2.2.31.tar.gz

tar –xzf openssl-1.0.2g.tar.gz

tar –xzf apr-1.5.2.tar.gz

tar –xzf apr-util–1.5.4.tar.gz

Step 3

install the packages like below.

1. Install Openssl

cd openssl-1.0.2g

Now configure the openssl with below command

./config –prefix=/usr/openssl –openssldir=/etc/ssl –libdir=lib shared zlib-dynamic

Now recompile with make command

make

Now install the packages to their proper location run the make install.

make install

if you have face any issue on this process then simply clear this with below command.

make clean

2. Install apr-1.5.2

now go to the apr-1.5.2 directory and do the following steps.

cd apr-1.5.2

./configure –prefix=/usr/apr-1.5.2

and recompile with

make

and install with

make install

3. Install apr-util-1.5.4

Go to the apr-util directory and do the following steps.

./configure  –prefix=/usr/apr-util-1.5.4 –with-apr=/usr/apr-1.5.2 –with-openssl=/usr/openssl –with-crypto

and recompile with

make

and install with

make install

4. install httpd-2.2.31

Before configure export the openssl library path so apache will access th so files through openssl

export LD_LIBRARY_PATH=/usr/openssl/lib

Now configure with following command.

./configure –prefix=/usr/local/apache2 –enable-ssl –enable-so –enable-deflate –enable-headers –enable-proxy –enable-proxy-connect –enable-proxy-http –enable-proxy-ajp –enable-proxy-balancer –with-ssl=/usr/openssl –enable-ssl-staticlib-deps –with-apr=/usr/apr-1.5.2/bin/apr-1-config –with-apr-util=/usr/apr-util-1.5.4/bin/apu-1-config

and recompile with

make

and install with

make install

5. Copy the modules to appropriate location

cp mod_jk.so mod_jk-1.2.31-httpd-2.2.x.so /usr/local/apache2/modules/

Step 4

Now configure apache configuratio for ssl authentication.

Now go to apache configuration location.

cd /usr/local/apache2/conf

now edit  the httpd.conf file

vi httpd.conf

in editor find the location of following senence (# LoadModule foo_module modules/mod_foo.so)

/# LoadModule foo_module modules/mod_foo.so

on below of that just add the mentioned details below

DocumentRoot “/usr/local/apache2/htdocs”
LoadModule   jk_module              modules/mod_jk-1.2.31-httpd-2.2.x.so
LoadModule   jk_module              modules/mod_jk.so
JkExtractSSL On
JkHTTPSIndicator HTTPS
JkSESSIONIndicator SSL_SESSION_ID
JkCIPHERIndicator SSL_CIPHER
JkCERTSIndicator SSL_CLIENT_CERT
#JkWorkersFile  “/usr/local/apache2/conf/workers.properties”
JkLogFile               “/usr/local/apache2/logs/mod_jk.log”
JkShmFile               “/usr/local/apache2/logs/jkshmi.log”
JkLogLevel              error

Now goto the last line on the page and find the Include conf/extra/httpd-ssl.conf and remove the # from that for enable ssl.
Now save and close the file.

Step 5

Now configure httpd-ssl.conf. Before that download the ssl certificate files from ftp://172.16.200.53/apache  and extract it in the required location.

now edit and add the following details in it and put # to below details.

vi extra/httpd-ssl.conf

and find <VirtualHost _default_:443> this line and add the following details and # the following detail


add hostname as like below

ServerName HOSTNAME:443

now add the certicate with appropriate locations

SSLCertificateFile “/u01/apache/GeoTrust/ssl/ssl_certificate.crt”

SSLCertificateKeyFile “/u01/apache/GeoTrust/ssl/*RSA_private.key”

SSLCertificateChainFile “/u01/apache/GeoTrust/ssl/IntermediateCA.crt”

Now # the following lines located in the same file in different line

#SSLCertificateFile

#SSLCertificateKeyFile

That’s all now start the apache and put the ssl certificate password like below.

go to apache bin directory

cd /usr/local/apache2/bin

now start the apache with below command

./apachectl -k start
 
provide the password and check with below command that your apache running or not.

ps -ef | grep apache


Step 6

For redirectng we have few options mentioned below.
  1. ProxyPass
  2. Redirection
  3. Rewrite
1. ProxyPass
ProxyPass is a router in Apache. It redirect the user request to the origin and hides the origin from the clients and others.

for example:

ProxyPass “/content” “http://ipaddress:port/content”
ProxyPreserveHost On

Note: contend should be same other wise redirection will not work properly.

After completing this we can access  without port we can use content. Type in the browser like below.

http://ipaddress/content

2. Redirection

Redirection is redirect a request to port to another with content or whatever it is, for this we need to configure virtualhost.

Redirection have two options temporary redirection and permanent redirection. Below temporary redirection and permanent redirection in  rewrite section.

for example:

Any request received by 80 it will redirect to 443 port.

<VirtualHost *:80>
  ServerName hostname or IP
  DocumentRoot /usr/local/apache2/htdocs
  Redirect / https://hostname or IP/content/
</VirtualHost>

https://ipaddress/content

3. Rewrite

It’s most powerful module that will redirect to rewrite the request without any negotiation.

Example:

<VirtualHost *:80>
  ServerName Hostname or IP
  RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
  Redirect permanent / “https://IP-address”
</VirtualHost>

Now stop and start the Apache and check everything will work perfectly.

That’s all. For any suggestions or any please command or reply in below.

No comments:

Post a Comment

Permanent hostname setup for RHEL7

Step 1 Set the host name on NMTUI tool like following nmtui set host name   then save and exit Step 2 add the following l...