#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    5
    Rep Power
    0

    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?
  2. #2
  3. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,118
    Rep Power
    1990
    It's not to hard. Pretty much every web server works the same way.

    1. OS receives the network request on port 80
    2. OS passes the request to web server (Apache)
    3. Apache thread is spawned to handle the request
    4. Apache decides on what action to take depending on mime/file extension settings.
    5. For .php files, invoke the PHP parser and for the requested file
    6. PHP parses the file and returns the output to Apache
    7. 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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    5
    Rep Power
    0
    Originally Posted by Catacaustic
    It's not to hard. Pretty much every web server works the same way.

    1. OS receives the network request on port 80
    2. OS passes the request to web server (Apache)
    3. Apache thread is spawned to handle the request
    4. Apache decides on what action to take depending on mime/file extension settings.
    5. For .php files, invoke the PHP parser and for the requested file
    6. PHP parses the file and returns the output to Apache
    7. 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.
    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?
  6. #4
  7. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,118
    Rep Power
    1990
    Originally Posted by jiminssy
    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?
    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.
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    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.

IMN logo majestic logo threadwatch logo seochat tools logo