httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boyle Owen" <Owen.Bo...@swx.com>
Subject RE: [users@httpd] running multpiple copies of httpd simultaneously
Date Tue, 07 Sep 2004 07:55:41 GMT
> -----Original Message-----
> From: bruce [mailto:bedouglas@earthlink.net]
> Sent: Montag, 6. September 2004 16:48
> To: users@httpd.apache.org
> Subject: RE: [users@httpd] running multpiple copies of httpd
> simultaneously
> 
> 
> you imply/state that i can stop a given instance of the 
> apache daemon by running:
> 
> stop 1:
> httpd -f server_root_1/conf/httpd_1.conf stop
> 
> this doesn't work... using the 'stop' attribute after the 
> '-f' doens't seem to have an effect.

Sorry - I was a bit hasty and confused httpd with apachectl. Forget the previous post...

Background:

The apache binary (ie, the actual machine-code program that your computer loads and runs)
is called "httpd" and is usually found in /usr/local/apache/bin/httpd. This program takes
a limited set of arguments, including "-f" to define the config file (see "man httpd" for
others). To start apache you normally just type "httpd" (assuming /usr/local/bin is on your
path) as you do for any executable. To stop it, you have to "kill <PID>" as you do for
any executable.

To insulate the user from such low-level activities, there exists also a shell-script called
/usr/local/apache/bin/apachectl. It is apachectl which takes the areguments "start" and "stop".
Please take a moment to locate this file and read it (more, less, cat, vi, xemacs - whatever).
It is just a shell-script so is quite readable and is well-commented. 

If you look near the top, you will find a line like:

HTTPD=/usr/local/apache/bin/httpd

Lower down, in the case block, you will see that "start" corresponds to simply executing $HTTPD.
This means that the binary will look in its default location for a config file, usually /usr/local/apache/conf/httpd.conf.

You will also see:

PIDFILE=/usr/local/apache/logs/httpd.pid

Read the code further and you will see that "stop" corresponds to reading the PID from this
file and doing a "kill PID".

So the lesson is that the out-of-the-box apachectl is great for one instance of apache. 

HOW-TO:

If you need more than oneinstance, I would recommend the following procedure:

- keep a single server root (eg, /usr/local/apache). Just have two config files and two pidfiles.

- make two additional copies of apachectl; call them apachectl_1 and apachectl_2

- in each one, edit the HTTPD and PIDFILE lines like this:

in apachectl_1:
HTTPD="/usr/local/apache/bin/httpd -f /usr/local/apache/conf/httpd_1.conf"
PIDFILE="/usr/local/apache/logs/httpd_1.pid"

in apachectl_2:
HTTPD="/usr/local/apache/bin/httpd -f /usr/local/apache/conf/httpd_2.conf"
PIDFILE="/usr/local/apache/logs/httpd_2.pid"

- in each config file, edit the PidFile directive thus;

in httpd_1.conf:
PidFile logs/httpd_1.pid

in httpd_2.conf:
PidFile logs/httpd_2.pid

NB: The two configs must listen to different TCP/IP sockets (ie, different IP/port combinations)

- you might also want to have two sets of logfiles as well;

in httpd_1.conf:
TransferLog logs/access_1_log
ErrorLog logs/error_1_log

in httpd_2.conf:
TransferLog logs/access_2_log
ErrorLog logs/error_2_log

- now do "apachectl_1 start"
	- do "ps -ef | grep httpd" to check its running
	- check httpd_1.pid is created

- now do "apachectl_2 start"
	- do "ps -ef | grep httpd" to check its running
	- check httpd_2.pid is created

see how that works..

Rgds,
Owen Boyle
Disclaimer: Any disclaimer attached to this message may be ignored. 

> 
> the docs all state/imply that '-k start|stop' is the way to 
> start/stop, but i don't see a way to specify the given 
> instance out of the various instances i've created...
> 
> so, the question still remains, how does one stop a given 
> instance of the apache httpd process... (without doing a kill -9 pid)
> 
> thanks
> 
> -bruce
> 
> 
> -----Original Message-----
> From: Boyle Owen [mailto:Owen.Boyle@swx.com]
> Sent: Monday, September 06, 2004 1:38 AM
> To: users@httpd.apache.org; bedouglas@earthlink.net
> Subject: RE: [users@httpd] running multpiple copies of httpd
> simultaneously
> 
> 
> > -----Original Message-----
> > From: bruce [mailto:bedouglas@earthlink.net]
> > 
> > in trying to run multiple copies of apache simultaneously on 
> > one server, i
> > did a
> >   httpd -k start (1st instance)
> > followed by:
> >   httpd -f /dir/to/diff.conf  (next instance)
> > 
> > doing a ps -ef appears to show two different instances of 
> > httpd running..
> > i changed the listen port in the 2nd to be 82.
> > 
> > my question..  how can i stop either one of the httpd apps 
> by doing a
> > http -stop...???
> 
> Depends if the two instances have different log directories... When it
> starts, apache stores the parent PID in logs/httpd.pid. When 
> you want to
> stop it, it reads this file to get the PID of the process to kill.
> 
> The easiest way to proceed is to have two server-root directories each
> containing a separate conf and logs directory, eg:
> 
> server_root_1/conf/httpd_1.conf:
> server_root_1/logs
> 
> and 
> 
> server_root_2/conf/httpd_2.conf:
> server_root_2/logs
> 
> the apache binary can be anywhere, you just make sure you 
> always specify
> the config file when you stop or start apache:
> 
> start 1:
> httpd -f server_root_1/conf/httpd_1.conf start
> (will write PID to server_root_1/logs/httpd.pid)
> 
> start 2:
> httpd -f server_root_2/conf/httpd_2.conf start
> (will write PID to server_root_2/logs/httpd.pid)
> 	
> Then 
> 
> stop 1:
> httpd -f server_root_1/conf/httpd_1.conf stop
> 
> stop 2:
> httpd -f server_root_2/conf/httpd_1.conf stop
> 
> Alternatively, you can mess around with the PidFile, ServerRoot
> directives etc.
> 
> Rgds,
> Owen Boyle
> Disclaimer: Any disclaimer attached to this message may be ignored. 
> 
> > 
> > i'd rather be able to gracefully do a stop, as opposed to 
> > killing it by
> >  'kill -9 pid...'
> > 
> > 
> > thanks..
> > 
> > -bruce
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP 
> > Server Project.
> > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> > 
> > 
> Diese E-mail ist eine private und persönliche Kommunikation. Sie hat
> keinen Bezug zur Börsen- bzw. Geschäftstätigkeit der SWX Gruppe. This
> e-mail is of a private and personal nature. It is not related to the
> exchange or business activities of the SWX Group. Le présent 
> e-mail est
> un message privé et personnel, sans rapport avec l'activité 
> boursière du
> Groupe SWX.
> 
> This message is for the named person's use only. It may contain
> confidential, proprietary or legally privileged information. No
> confidentiality or privilege is waived or lost by any mistransmission.
> If you receive this message in error, please notify the 
> sender urgently
> and then immediately delete the message and any copies of it from your
> system. Please also immediately destroy any hardcopies of the message.
> You must not, directly or indirectly, use, disclose, 
> distribute, print,
> or copy any part of this message if you are not the intended 
> recipient.
> The sender's company reserves the right to monitor all e-mail
> communications through their networks. Any views expressed in this
> message are those of the individual sender, except where the message
> states otherwise and the sender is authorised to state them to be the
> views of the sender's company. 
> 
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP 
> Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
Diese E-mail ist eine private und persönliche Kommunikation. Sie hat keinen Bezug zur Börsen-
bzw. Geschäftstätigkeit der SWX Gruppe. This e-mail is of a private and personal nature.
It is not related to the exchange or business activities of the SWX Group. Le présent e-mail
est un message privé et personnel, sans rapport avec l'activité boursière du Groupe SWX.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message