goh
goh

Reputation: 29511

How does the apache lifecycle looks like?

As part of my learning process, I thought it would be good if I expand a little more knowledge on what I know about apache. I have several questions, and while I know some of the stuff may require a rather lengthy explanation, I hope you can provide an overview so I know where to go looking. (preferably reference to mod_wsgi)I have read some resources after searching on google, and what I know arrive from there, so please bear with me.

  1. What does the apache lifecyle looks like before, during, and after it receives a http request? Does it spawns a new child process to do the work, or creates a thread in one of the child process?

  2. Does apache by default runs under www-data? So if that's the case, if I want a directory under my project folder to be used for logs, I can change just the folder group to www-data and allows write access?

  3. What user will the python interpreter run under, after being invoked by apache? And what will processes created by Popen or multiprocessing from there run under?

  4. I ran ps U www-data. Why are there so many processes with

S 0:00 /usr/sbin/apache2 -k start

Upvotes: 2

Views: 1269

Answers (2)

Tobias Schlegel
Tobias Schlegel

Reputation: 3970

The Apache mpm prefork module handles one connection in one process. To handle connections fast and not spawn processes on demand, apache maintains a process-pool. This explains why you see so many processes in the process-list. If a connection comes in, it is handed to one of the already existing processes.

Some more information is here: http://httpd.apache.org/docs/2.0/en/mod/prefork.html

The answer to question 2) is yes, apache always runs as www-data und you can grant access to any directory by changing it's group permissions to www-data.

Upvotes: 2

Related Questions