Site Moved

This site has been moved to a new location - Bin-Blog. All new post will appear at the new location.

Bin-Blog

Multiple Versions of Apache on a Single System

Some times it is necessary to have multiple versions on Apache in your system. The system I am currently working on has two versions of Apache - the first is Apache 1.3 with PHP 4 and MySQL 3. The second apache is Apache 2.0 with PHP 5 and MySQL 5. It is very easy to install multiple versions of Apache in your system - the only limitation is that you can't have all the versions run at once - only one instance of apache must be running at any one point.

I installed multiple versions of apache by using the 'prefix' keyword while compiling the software. To do this, you must have the source tarball of the apache program. Install it using the commands...

./configure --prefix=/usr/local/apache2
make && make install

The prefix keyword is the location where apache will be installed to. When create multiple installation of apache, keep changing this location - so that the previous installation will not be overwritten. You can start apache using the command...

/usr/local/apache2/bin/apachectl start

This command will start the apache server at /usr/local/apache2/ folder. The configuration files for this installation will be at /usr/local/apache2/conf/. Open the folder '/usr/local/apache2/' and you will see the other folders in this directory - like document root, logs etc. You can change the default locations of these folders using the httpd.conf file.

Apache can be stopped using any one of the following commands...

service httpd stop

OR

/usr/local/apache2/bin/apachectl stop

Make sure that the running instance of Apache is stopped before starting a new instance - else a failure message will be shown. You can do this by using the command line...

$ service httpd stop
Stopping httpd:                        [  OK  ]
$ /usr/local/apache2/bin/apachectl start

Or you can use a neat script I created in Tcl/Tk. Save the following code into a file, say, 'ApacheRemote.tcl' and execute it using the command 'wish ApacheRemote.tcl'. NOTE: You must have Tcl/Tk on your system for this to work.


#!/usr/bin/wish
# ApacheRemote V 2.00.A
# http://www.bin-co.com/tcl/

proc showMsg { result } {
 .txt insert end "$result\n"
}

############################### GUI Code ####################################
label .lab_top -text "Apache Remote"
pack .lab_top

frame .frm_common
button .frm_common.but_stop -text "Stop Apache" -command {
 catch { exec "service" "httpd" "stop" } result
 showMsg $result
}
button .frm_common.but_status -text "Status" -command {
 catch { exec "service" "httpd" "status" } result
 showMsg $result
}
pack .frm_common.but_stop .frm_common.but_status -side left
pack .frm_common

frame .frm
button .frm.but_start -text "Start /usr/local" -command {
 catch { exec "/usr/local/apache/bin/apachectl" "start" } result
 showMsg $result
 #exit
}
button .frm.but_start_default -text "Start Default" -command {
 catch { exec "service" "httpd" "start" } result
 showMsg $result
 #exit
}

pack .frm.but_start .frm.but_start_default -side left
pack .frm

#Result Display Area
text .txt 
pack .txt -fill both -expand 1 -side top

bind . <Key-Escape> { exit }

Filed Under...

1 Comment:

Anonymous said...

nice blog.