Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
415 views
in Technique[技术] by (71.8m points)

php - Creation of new process for each request of web page?

It might be a basic question but everytime a user call a php file from a server, does it create a new process from that server ?

For example, I have a basic form (let's say on index.php) that submits a text to another php file. In that php file, I print the posix_getpid().

I opened in two tabs my index.php an filled in and submitted a text and I ended up with two different pid on each tab.

Which lead me to the conclusion that a server probably create a new process for each script. Am I right ?

Cheers !

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I assume that you're running apache as your web server.

When a request comes in, apache starts a new thread. PHP is then invoked on this new thread, hence why you get a new process id every time.

This is, of course, greatly simplified.

I recommend reading this article for a deeper understanding.

Edit: It seems that the process differs between platforms. It works the way I described above on Windows, but multiple apache processes are executed on Unix.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...