December 7th, 2011, 09:27 PM
Something puzzling about LAMP technology bundle
Linux - OS for your server machine
Apache - daemon that handles HTTP requests
MySQL - database
PHP (or any other) - server side scripting language
I know what each one is but having hard time how they fit together as a bundle.
Let's say a request comes in for some website, Apache's servlet is spun up as a new thread and when and how does PHP kick in? I've done a bit of servlet and PHP programming separately before but never understood how web servers serve up the sites. Could somebody shine a light?
December 7th, 2011, 10:58 PM
It's not to hard. Pretty much every web server works the same way.
- OS receives the network request on port 80
- OS passes the request to web server (Apache)
- Apache thread is spawned to handle the request
- Apache decides on what action to take depending on mime/file extension settings.
- For .php files, invoke the PHP parser and for the requested file
- PHP parses the file and returns the output to Apache
- Apache returns the file output in response to the network request.
That is a bit of a simplified version, but essentially that's all that it is. The PHP module is invoked by Apache to do all of it's processing work before the result is returned to the user.
December 8th, 2011, 06:10 AM
So all the Apache does, in the case of PHP file request, is delegating the work to the PHP parser? The real web page related work is done by your PHP script in the PHP page?
Originally Posted by Catacaustic
December 8th, 2011, 04:22 PM
Yes, that's exactly it. Apache is basically just a handler. It doesn't do any sort of processing of the page content itself, it just passes back what it's told to.
Originally Posted by jiminssy
December 9th, 2011, 09:28 AM
Apache's actual superpower is allowing your computer (which can only process half a dozen things at a time) to handle hundreds of simultaneous web requests. In the very basic model, apache is a listener on port 80 that throws all requests out to PHP. In the more complex model, it's what keeps thousands of simultaneous requests running without any of them taking longer than 2 seconds.
HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002
Think we're being rude? Maybe you asked a bad question
or you're a Help Vampire.
Trying to argue intelligently? Please read this.