Httpd Concepts: Difference between revisions
Line 14: | Line 14: | ||
==Graceful Stop== | ==Graceful Stop== | ||
When the httpd server is "gracefully stopped", the parent advises the children to exit after serving the current request - or exit immediately if they are not serving anything. Then the parent will remove its [[httpd PidFile|PidFile][ and cease listening on any ports. The parent will continue to run and monitor the children which are still handling requests. Once all children have finished handling requests and exited, or the [[httpd GracefulShutdownTimeout]] has passed, the parent will also exit. If the timeout is reached while the children are still handling requests, they will be forced to exit. | |||
[[Linux_Signals#SIGWINCH_.2828.29|WINCH]] | [[Linux_Signals#SIGWINCH_.2828.29|WINCH]] | ||
==Graceful Restart== | ==Graceful Restart== |
Revision as of 20:38, 2 January 2017
Internal
Server Lifecycle
The httpd server, which may consist in several OS processes, can be stopped and restarted by sending Unix signals into the parent process. Under normal circumstances, you should never have to interact with the child processes. There are four types of lifecycle events httpd can go through, and they correspond to four different Unix signals, described below. The signals can be sent into the parent process using the httpd process directly, using the -k command line options or (recommended) the apachectlcontrol script. For more details on how to operationally control the lifecycle see "Controlling httpd Lifecycle" article.
Stop Now
When the httpd server is "stopped now", the parent immediately attempts to kill all of its children. Then the parent itself exits. Any requests in progress are terminated, and no further requests are processed. "Stop now" is achieved by sending the TERM signal or "stop" command into the parent.
Graceful Stop
When the httpd server is "gracefully stopped", the parent advises the children to exit after serving the current request - or exit immediately if they are not serving anything. Then the parent will remove its [[httpd PidFile|PidFile][ and cease listening on any ports. The parent will continue to run and monitor the children which are still handling requests. Once all children have finished handling requests and exited, or the httpd GracefulShutdownTimeout has passed, the parent will also exit. If the timeout is reached while the children are still handling requests, they will be forced to exit.
Graceful Restart
Restart Now
The Parent Process
The httpd parent process is the process whose PID is written in PidFile. Under normal circumstances, the lifecycle of the entire server, consisting in a parent process and several children, can be controlled by sending signals into the parent process only,
Multi-Processing Module (MPM)
Proxying Concepts
Context
- Server Configuration (httpd.conf)
- Virtual Host
- Directory
Virtual Host
- External Apache 2.4 Documentation - Virtual Hosts http://httpd.apache.org/docs/2.4/vhosts/
Overview
A virtual host is a container within a httpd instance serving a single logical web site. Multiple, separate web sites, even belonging to different domains, can be served off the same httpd instance without that being apparent to the client. The virtual hosts can be name-based or ip-address based.
Name-Based Virtual Host
The server relies on the client sending a "Host" HTTP header. It uses the value to locate the correct logical host. This technique allows many different virtual hosts to share the same IP address. The web browser must cooperate by sending the correct "Host" header, as part of each request.
Name-based virtual hosting is the preferred technique, unless you're using equipment that explicitly demands IP-based hosting.
IP Address-Based Virtual Host
IP-based virtual hosts use the IP address of the connection to determine the correct virtual host to serve. Therefore you need to have a separate IP address for each host.
Virtual Host Configuration
A virtual host is declared in the httpd configuration using the <VirtualHost> configuration element. More details on virtual host configuration:
SSL Support
httpd provides SSL/TLS encryption support via the mod_ssl module, which is an interface to OpenSSL library. More details about SSL configuration are available here: