Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Update: Responding to the comment:

check processes of apache:

$ ps a | grep apache 3
grep: 3: No such file or directory
$ ps a | grep apache
 4514 pts/0    S+     0:00 grep --color=auto apache
$ ps a | grep apache2
 4516 pts/0    S+     0:00 grep --color=auto apache2

checking apache error log

$ tail /var/log/apache2/error.log
[Sun Aug 07 03:14:19 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.5 with Suhosin-Patch configured -- resuming normal operations
[Mon Aug 08 03:13:58 2011] [notice] Graceful restart requested, doing restart
[Mon Aug 08 03:14:00 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.5 with Suhosin-Patch configured -- resuming normal operations
[Mon Aug 08 09:03:16 2011] [notice] caught SIGTERM, shutting down
[Mon Aug 08 09:05:47 2011] [notice] Apache/2.2.16 (Ubuntu) PHP/5.3.3-1ubuntu9.5 with Suhosin-Patch configured -- resuming normal operations

Original: I have stopped apache, but why it still has the same number of processes running?

$ ps -A | grep apache
 1663 ?        00:00:00 apache2
 1667 ?        00:00:00 apache2
 1668 ?        00:00:00 apache2
 1669 ?        00:00:00 apache2
 1670 ?        00:00:00 apache2
 1671 ?        00:00:00 apache2
$ /etc/init.d/apache2 stop
 * Stopping web server apache2                            [ OK ] 
$ ps -A | grep apache
 1663 ?        00:00:00 apache2
 1667 ?        00:00:00 apache2
 1668 ?        00:00:00 apache2
 1669 ?        00:00:00 apache2
 1670 ?        00:00:00 apache2
 1671 ?        00:00:00 apache2

Thanks!

share|improve this question
    
(Sorry I can't comment 'cause I've not enough rep.) 1. Is the web servier still available with a web browser? 2. Check the status of your processes. They may have become "Zombie processes" ps a | grep apache 3. Check the error logs, the may be useful tail /var/log/apache/error.log –  SamK Aug 8 '11 at 13:45
    
1. I am using firefox. It is my laptop. 2 and 3 see my update. –  Tim Aug 8 '11 at 14:08
    
Have u tried this 'apache2 -k stop' or a 'apache2 -k restart'? or a restart of your system? –  blade19899 Sep 10 '12 at 12:15

4 Answers 4

This can happen occasionally when Apache refuses to stop nicely or has Zombie Processes. For the former you can kill all running processes with sudo killall -9 apache2; however, for the latter you'll simple need to wait for them to go away. In the event it's Apache not wanting to stop nicely, what you'll really want to do is investigate what's going on. Finding out exactly what's going on can be difficult though.

An interactive strace of the process id may lend a clue as to what site(s) are acting up and causing issues. From your above ps -A you can check the first process with

strace -p 1663

This will attach to the running processes stack trace providing live output of what is going on. At any time you can Ctrl+C

An additional resource is the main error log for Apache this can be found in /var/log/apache2/error.log You'll want to get a decent chunk of the log and skim it for details. If the problem is an ongoing issue running

tail -f /var/log/apache2/error.log

This similar to the strace will run in realtime. For the last N lines replace -f with -# where the # is a positive number like 50, 100, 282, etc.

share|improve this answer

Processes can be asked (by sending a signal to them) to stop. The kill command is a way to do that. If you know the process ID (PID) of the process, it can be asked nicely by running the command below in a terminal:

kill PID_OF_YOUR_PROCESS

The above example sends the PID the default TERM signal (code 15). You can look up the signal codes in the man page of kill (man kill).

When the program disregards the TERM signal sent to them, it is still possible to apply a bit more pressure by sending the KILL signal (code 9). This signal is used as a last resort, because the process might not save any unsaved data.

Specifying a -SIGNAL_CODE as the first parameter before the process ID will send the process the specific signal. Another useful feature of the kill command is that you can specify more PIDs as in the following example:

kill -9 PID1 PID2 PID3 PID4

Try to terminate the Apache processes by using the kill -9 line. They should stop unless something blocks them from doing so.

share|improve this answer

I too had the same problem, and tried the following:

sudo apache2ctl stop

to stop the service, and

sudo apache2ctl start

to start it again.

It works for me, any possible suggestions are welcome.

share|improve this answer

make sure you have proper permissions to stop the service

if you run

    service apache2 stop

you will not get any error just: * Stopping web server apache2 try

    sudo service apache2 stop      
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.