Starting and Stopping Apache
Why stop and start your web server?
Apache can run several ways:
- On Unix, invoked by Inetd
- On-demand, when a request for a web page is received
- Saves memory
- Responds slowly because it must be invoked from scratch for every web page
- Useful only for lightly-used web servers
- Not available on Win32 (Win32 has no inetd)
- To configure, add this line to
and add this line to
(substitute for the pathname as appropriate)
http stream tcp nowait root /usr/sbin/httpd httpd
- Make sure you have an
If you don't, edit the appropriate rc file to get it to start automatically.
- Send it the
SIGHUP signal to make it reread its config files.
- As a daemon (Unix) or a service (Win32)
- "Standalone" mode
- Runs all the time
- Restarts automatically at boot
- On Win32, in a "console window"
- It runs only when you are logged in...
- And when you explicitly run it.
- For testing and experimentation.
How to Stop and Restart the Server
kill -SIGHUP `cat httpd.pid`
- Send the signal to the parent process, not any of its children.
If you kill a child, the parent will simply restart it.
- Win32 console
- In a DOS window:
net stop apache
net start apache
- Win32 service
- Use the
Services applet in NT's or Win2K's Control Panel.
- Hint: start menu -> programs -> administrative tools -> services
- See whether Apache is running -- click here:
- If it is, stop it.
- Verify that it's not running (click above).
Observe that you get only an error.
- Restart it.
- Verify that the document is now delivered (click above).
- Again, shut it down.
- Next, restart it from a console window.
- Watch what happens in the Apache Services applet.
- Again, verify that it's working (click above).
What Web Servers Do
- Now your web server is running... what is it doing, exactly???
- It's servicing HTTP requests.
- That's why it's called HTTPD (daemon).
- But what's HTTP? What's an HTTP request?
Hand-Simulation of an HTTP Client
- Invoke telnet.
- Connect to any HTTPD out there on the web via port 80,
one of the standard
- Give it an HTTP request.
- See how the server responds.
- This technique is useful... why?