Apache Installation Configuaration
Apache HTTP webserver complete references for Installation and configurations are prepared by Sarangapani in 2009. Again in 2012 this same wheel reinvented by Brahmaiah in much detail and advanced configurations.
Apache HTTP server installation can be done in two possible ways on UNIX. You can install with root user or non-root user access. Select your strategy, If your environment is providing root access to you then you can install Apache with rpm package installation for each UNIX flavor is differs. When I am updating this page the latest stable version of Apache HTTP Server is 2.4.2. This version will provide you a hybrid multi-threaded, multi-process architecture supporting that is compatible and thread-safe for plugins.
Apache HTTP Installation steps that Saranga have followed for sharing here are on Solaris machine.
1. Get Latest Apache installation procedure
2. Configuring Apache Server
Step 1: Download the any stable version of httpd for your operating environemnt (Now I am intersted in Solaris) suitable binaries given as tar/zip file (Ex: httpd-2.2.11.tar) and Extract it
Apache HTTP 2 and Latest downloads
$ gunzip httpd-2.4.2.tar.gz
Unzip and extract tar file
$ tar -xvf httpd-2.4.2.tar
Pre Check: Verify that C compiler is available in the PATH and LD_LIBRARY_PATH. otherwise set it with your UNIX Admin. You can confirm this by checking 'gcc' command execution.
Step 2: Go to httpd-2.2.11 directory and execute the confiure command to configure the apache in one folder (Ex: apache2)
$ cd httpd-2.2.11
$ ./configure --prefix=$Home/apache2
Here you can choose selective options to include multiple modules to your binaries.
Step 3: We need to execute the below commands to build, compile the binaries with the C compiler
$ make
This will consumes queit lot of your time... You can have a Tea break in between :)
$ make install
#The below are the extracted files of apache tar file :
bash-3.00$ pwd
Home/wluser/apache2
bash-3.00$ ls -ltr
total 116
drwxr-xr-x 2 wluser project 1024 May 22 2008 lib
drwxr-xr-x 3 wluser project 4096 May 22 2008 icons
drwxr-xr-x 3 wluser project 1024 May 22 2008 error
drwxr-xr-x 2 wluser project 96 May 22 2008 cgi-bin
drwxr-xr-x 4 wluser project 96 May 22 2008 man
drwxr-xr-x 2 wluser project 30723. May 22 2008 include
drwxr-xr-x 14 wluser project 5120 May 22 2008 manual
drwxr-xr-x 2 wluser project 1024 May 22 2008 build
drwxr-xr-x 2 wluser project 1024 Nov 17 07:50 modules
drwxr-xr-x 3 wluser project 1024 Nov 17 08:37 bin
drwxr-xr-x 8 wluser project 2048 Nov 17 08:55 htdocs
drwxr-xr-x 11 wluser project 1024 Nov 17 09:00 logs
drwxr-xr-x 4 wluser project 1024 Feb 13 05:37 conf
Basic Configuration changes
1. Backup of Configuration
As part of implementation of best practices for infrastructure platform, We need to take the backup of the original httpd.conf file that is provided by Apache
cd apache2/conf
cp httpd.conf httpd.conf_original
Now Edit the httpd.conf configuration file any available editor, here in UNIX we usually use vi.
vi httpd.conf
basic changes
Listen xxxx
ServerName
How to create multiple Apache HTTP server instances?
Assume that you need two HTTP server instances on the same machine. How to do this? Apache Webserver expert will give a different solution.
This question can be answered different solutionYou need to configure individual httpd.conf file and that can be invoke by the bin/httpd command. Using -f option we can make sure that it will pick the individual configuration files. Otherwise it will always look in the default $APACHE_HOME/conf containing 'httpd.conf' file.
To work with multiple configuration files you need to modify or add the following directives to the individual httpd.conf files.
1. Listen the servername can be same but port must vary,
2. Provide the different access, error log paths.
3. PidFile directive must be given for each Apache instance that could store in respective logs folder
4. DocumentRoot you may wish to server same content by multiple Apache instances or you can selective for different content. So choose your option accordingly.
General Directives to update
Once you setup for basic test, you may wish to move towards load test environment or pre-production setup where you can copy the best setup made as basic configuration and update the following:
(1) PidFile path of the PID usually set into logs directory
(2) Timeouts
(3) MaxKeepAliveRequests
(4) prefork MPM: as per your Unix environment specify the below
(4.1) StartServers: number of server processes to start
(4.2) MinSpareServers: minimum number of server processes which are kept spare
(4.3) MaxSpareServers: maximum number of server processes which are kept spare
(4.4) MaxClients: maximum number of server processes allowed to start
(4.5) MaxRequestsPerChild: maximum number of requests a server process serves
(5) Listen <port# of the server>
(6) DSO(Dynamic Shared Object): Many Unix implementations provide the capability of specifying at run time which portions of an executable are to be included in httpd and which are to be excluded. The term for these precompiled chunks is shared objects. The main advantage of using DSOs is that you can effectively rebuild your server at run time by modifying the directives of your configuration file and restarting the server. Note, however, that not all operating systems support DSO functionality.
LoadModule weblogic_module modules/mod_wl_20.so (This is solaris 10 Module)
(7) user & group: should be defined if the apache server is installed on UNIX machine
(8) Apache - WebLogic proxy Cluster Configuration
The following Apache configuration is defined for WebLogic application server proxying with plugin.
There could be any extensions for the file you can say *.* but WebLogic server supports mostly JSP or servlets so choose accordingly. Following sample have the MatchExpression as *.jsp that allows access thru proxy request of all files extension as .jsp.
In most of the production environments we use WebLogic clusters proxying by webservers. The cluster of WebLogic servers are in the target list then one of the server might be failed that can be takeover with DyanamicServerList set to ON. The backend server all are not available then we get "Apache Bridge failed".
You are instructing Apache HTTP server to use the weblogic-handler it is written in mod_weblogic.c module.
The session can be sticky with WebLogic specific cookie that stores the JSessionID.
For production environments we don't wish to propagating logs for debug purposes so make that as OFF.
<IfModule mod_weblogic.c>
WebLogicCluster Server1 IP:PORT, Server2 IP:PORT ....ServerN IP:PORT
MatchExpression *.jsp
</IfModule>
<Location /yourcontext>
SetHandler weblogic-handler
DynamicServerList ON
HungServerRecoverSecs 600
ConnectTimeoutSecs 40
WLCookieName JSESSIONID
Debug OFF
DebugConfigInfo OFF
WLLogFile path for the log file
ConnectRetrySecs 2
Idempotent ON
FileCaching ON
WLProxySSL OFF
SecureProxy OFF
</Location>
(9) Idempotent: Set the this attribute to ON to server the requests durably
(10) SSL configuration: this is optional
(11) Error Logs: Set the path for error logs
(12) CustomLogs:
#The Below are the list of files under conf folder of apache:
bash-3.00$ cd conf
bash-3.00$ ls -ltr
total 276
-rw-r--r-- 1 wluser project 29430 May 22 2008 mime.types
-rw-r--r-- 1 wluser project 12958 May 22 2008 magic
-rw-r--r-- 1 wluser project 2035 May 22 2008 highperformance.conf
-rw-r--r-- 1 wluser project 11032 May 22 2008 ssl.conf
-rw-r--r-- 1 wluser project 11032 May 22 2008 ssl-std.conf
-rw-r--r-- 1 wluser project 35148 May 22 2008 httpd-std.conf
-rw-r--r-- 1 wluser project 2035 May 22 2008 highperformance-std.conf
-rw-r--r-- 1 wluser project 35183 May 22 2008 httpd.conf
drwxr-xr-x 2 wluser project 96 Oct 10 10:17 web1web1
bash-3.00$ pwd
Home/wluser/apache2063/conf
Create a directory of web instance under the conf directory and copy the existing httpd.conf file into that directory
bash-3.00$ mkdir wluserweb1
bash-3.00$ cd wluserweb1
bash-3.00$ cp ../web1web1/httpd.conf .
#update the httpd.conf file
---> Change the Apache Installation path
---> Change the Apache instance name
---> Change Apache Listen port (Listen HostName:portno)
--->mainly the following are need to update in the httpd.conf file
<IfModule mod_weblogic.c>
WebLogicCluster HostName:port
MatchExpression *.jsp
</IfModule>
<Location /webdir>
SetHandler weblogic-handler
DynamicServerList ON
HungServerRecoverSecs 600
ConnectTimeoutSecs 40
WLCookieName JSESSIONID
Debug OFF
WLLogFile Home/wluser/apache2063/logs/wluserweb1/wluserweb1.log
ConnectRetrySecs 2
Idempotent ON
FileCaching ON
WLProxySSL OFF
SecureProxy OFF
</Location>#go to bin directory which is under apache folder
Create webinstance script with the existing instance and update the installation path and instance name etc
bash-3.00$ cp apachectl wluserweb1
bash-3.00$ vi wluserweb1
---> Change the Apache Installation path
---> Change the Apache instance name
HTTPD='Home/wluser/apache2063/bin/httpd -f Home/wluser/apache2063/conf/wluserweb1/httpd.conf'
start script of webinstance (wluserweb1)
#Go to bin directory under webinstance folder to start the webinstance by using the start(ex: ./wluserweb1 start)
bash-3.00$ ./wluserweb1 start
bash-3.00$ ./wluserweb1 stop
bash-3.00$ ./wluserweb1 restart
Here in this command prefixing with ./ it is required only when you don't have your current path(.) in the environment PATH value.
To verify that HTTP service is running fine check with the following command:
ps -ef |grep httpd|grep -v grep
Apache Sample url :
The default index.html page is available from DocumentRoot that is pointed to $APACHE_HOME/htdocs.
http://HostIP:port(whichiskeptinhttpd.conf file)/ProjectName/jsp/Logon.jsp
Configuring a Virtual Host
Apache Installation, HTTP Server configuration, VirtualHost in Apache, compiling Apache binaries