Apache HTTP RPM installation

This page about rpm package installation is available only on Linux flavors. Why do we need this rpm? It is a bundled package with auto-executing script that runs when you install with rpm commands. Apache binaries can be recompiled when it is installed. It requires root access to execute this. We can also customize the rpm packages so that we can run the installer rpm that internally creates a dedicated apache user, that will be used to run the child threads of Apache HTTP server processes. Before you install the Apache HTTP server verifying the operating system processor instructional set it is 32bit/64bit.

Apache HTTP RPM package installation


Verify 32bit/64bit

[wladmin@sam-server]# uname –a

Linux bt-dante-server 2.6.32-100.26.2.el5 #1 SMP Tue Jan 18 20:11:49 EST 2011 x86_64 x86_64 x86_64 GNU/Linux

Why do we need this means? Based on these operating system capabilities 32bit or 64bit we need to select the Apache HTTP download the rpm.

Here we have experimenting by using 64bit supported installation rpm.

Some of the Linux environments installing the HTTP service as part of Operating system installation. So, Let us first check that is it already installed? the below command of rpm option will give the desired validation.

Verify Apache  installation  

First check already apache is installed using the rpm or not. By using the below rpm command we can confirm that this particular HTTP version exists in the installed packages.

[wladmin@sam-server]# rpm –q httpd-2.4.x-1.i686.rpm

package httpd-2.4.x-1.i686.rpm is not installed

Apache Installation using rpm 

Now everything ready, We can jump into installation of Apache HTTP that is bundled as rpm. Using the below rpm command we are going to install the Apache HTTP server. The options d -ivh means install, verbose, 

[wladmin@sam-server]# rpm -ivh httpd-2.4.x-1.i686.rpm

Preparing... ########################################### [100%]

Httpd-2.4.x-1.i686.rpm  ####################################[100%]

After installation, check the installation as said in the previous section. If there is any software package could be using the rpm and it may change some of your installation pack too. So better you can run the below command to update the Linux maintaining packages DB (update the locate rpm database)

[wladmin@sam-server]# updatedb

Uninstall apache rpm

This command you must know when there is problem while installing in the middle or there could be older version and you need to install new version. To remove the apache bundle that is already installed by using rpm (httpd-2.4.x-1.i686.rpm) then below rpm command with option –e is use to tell erase the httpd bundle from the packages .

[wladmin@sam-server]# rpm -e httpd-2.4.x-1.i686.rpm

Basic Apache Configuration 

Here we are going to discuss all the basic attributes that could enable you to start the Apache HTTP server instance

Listen

The Listen command tells the Web server what ports to use for incoming connections.

By default, port 80 is used, although any one or several can be used. Secure web communications are normally handled on port 443.

 Listen             ipaddress with port number (or) DNS with port number

By default configuration in httpdf.conf file

Listen 80 is replace  your DNS name with port Number. Here my DNS name is sam-server and port Number

 

Listen             172.31.231.62:6280            

(or)   

Listen   sam-server:6280

ServerName : This is the one setting you will have to change to get your server running. This is where you declare the name of your website.

ServerName ipaddress with port number (or) DNS Name with port Number

User and Group: According to our requirement to specify the apache Instance operations controlled username and Group

 

User wladmin

Goup wladmin

ServerName : This is the one setting you will have to change to get your server running. This is where you declare the name of your website.

ServerName ipaddress with port number (or) DNS Name with port Number

ServerName 172.31.231.62:6280 (or) sam-server:6280

Starting Apache Web server as Service

On UNIX / Linux platform Apache web server instance can be started as a service

service httpd start

How to find the Apache Process Running?

On the UNIX environments ps command can be used to find the list of process. To filter out the Apache instance we can use grep with keyword ‘httpd’.  The apache process is by using the below command 

 

$ ps –ef | grep httpd 

 

Configuring Multiple Apache Instances on a Machine

It is possible to configure additional instances of the Apache httpd server running independently alongside each other on the same machine. These instances can have independent configurations, and can potentially run as separate users if so configured.

To create an additional Apache HTTP webserver instance called httpd-additional, follow these steps:

Go to $APACHE_HOME/conf directory, here create two directories(as per your requirement it can be more than two) with the names SideA and SideB

[wlamin@sam-server conf]# pwd

/home/wladmin/apache2/conf

[wladmin@sam-server conf]#mkdir SideA

[wladmin@sam-server conf]#mkdir SideB

By using the cp command copy the default configuration file into new directories created above such as SideA and SideB

[wladmin@sam-server]#cd SideA

 [wladmin@sam-server SideA]#cp /home/wladmin/apache2/conf/httpd.conf .

[wladmin@sam-server conf]cd ../SideB

 [wladmin@sam-server SideB]#cp /home/wladmin/apache2/conf/httpd.conf .

Move to logs under the apache2 and create two directories with the names SideA-logs and SideB-logs

[wladmin@sam-server SideA]#cd ../..

[wladmin@sam-server logs]#mkdir SideA-logs

[wladmin@sam-server logs]#mkdir SideB-logs

sideA apache Instance logs are placed inside the /home/wladmin/apache2/logs/SideA-logs

[wladmin@sam-server logs]#cd SideA-logs

[wladmin@sam-server logs SideA-logs]#pwd

/home/wladmin/apache2/logs/SideA-logs

sideB apache Instance logs are placed inside the /home/wladmin/apache2/logs/SideB-logs

[wladmin@sam-server logs]#cd SideB-logs

[wladmin@sam-server logs SideB-logs]#pwd

/home/wladmin/apache2/logs/SideB-logs

Go to /home/wladmin/apache2/conf/SideA and edit the configuration file(httpd.conf) according to our basic requirement to run the web server we need following directives configuration.

Listen, ServerName, ErrorLog, CustomLog and PidFile.

Listen             172.31.231.62:6280 (or)   sam-server:6280

ServerName 172.31.231.62:6280 (or) sam-server:6280

ErrorLog        /home/wladmin/apache2/logs/SideA-logs

CustomLog    /home/wladmin/apache2/logs/SideA-logs

PidFile            /home/wladmin/apache2/logs/SideA-logs

Go to /home/wladmin/apache2/conf/SideB and edit the configuration file(httpd.conf) according to our requirement.

Listen, ServerName, ErrorLog, CustomLog and PidFile.

Listen             172.31.231.62:6290 (or)   sam-server:6290

ServerName 172.31.231.62:6290 (or) sam-server:6290

ErrorLog        /home/wladmin/apache2/logs/SideB-logs

CustomLog    /home/wladmin/apache2/logs/SideB-logs

PidFile            /home/wladmin/apache2/logs/SideB-logs

Go to the path /home/wladmin/apache2/bin. Here one file is located with the name apachectl. It is used to start the apache Instance. Based on we can create separate instance startup file by passing with the configuration file path.

[wladmin@sam-server bin]# pwd

/home/wladmin/apache2/bin

[wladmin@sam-server bin]#cp apachectl apachectl-SideA

[wladmin@sam-server bin]#cp apachectl apachectl-SideB

Open the apachectl-SideA file and replace HTTPD = '/home/wladmin/apache2/bin/httpd with

HTTPD = '/home/wladmin/apache2/bin/httpd -f /home/wladmin/apache2/conf/SideA/httpd.conf '

[wladmin@sam-server bin]#vi apachectl-SideA

HTTPD = '/home/wladmin/apache2/bin/httpd -f /home/wladmin/apache2/conf/SideA/httpd.conf '

Open the apachectl-SideB file and replace HTTPD = '/home/wladmin/apache2/bin/httpd with

[wladmin@sam-server bin]#vi apachectl-SideB

HTTPD = '/home/wladmin/apache2/bin/httpd -f /home/wladmin/apache2/conf/SideB/httpd.conf '

To start the SideA apache Instance using the below command

./ apachectl-SideA start

To start the SideB apache Instance using the below command

./ apachectl-SideB start

 

Best Reference

1. Apache RPM installation

2. Failover in Apache with multiple instances

3. Multi Site setup 

 


Comments