9. PHP, LAMP and LEMP Step by Step
9.1 Static vs Dynamic and How PHP Runs
Static site madhe server fakt file uchalun deto. Dynamic site madhe server aadhi code chalavto (PHP), code database la vicharto, aani mag tayar zalela HTML pathavto.
Static: Browser --GET /about.html--> Nginx --reads file--> same HTML for everyone
Dynamic: Browser --GET /feed.php--> Nginx --FastCGI--> PHP-FPM --SQL--> MySQL
|
HTML built for THIS user <--+
| Way to run PHP | Used with | How it works |
|---|---|---|
mod_php |
Apache (common on Ubuntu) | PHP is loaded inside every Apache process |
| PHP-FPM | Nginx (always), Apache on Amazon Linux | Separate pool of PHP worker processes; web server talks to it over a unix socket (FastCGI) |
Why this matters for security
Dynamic code is where most serious web vulnerabilities live – SQL injection, XSS, file upload, command injection (Part 11). A static site has very little to attack; a PHP app that talks to a database has a lot. That is why we build one ourselves before we attack one.
Ravindra Bagale's Tip
Khup students la vatte PHP browser madhe chalto. Nahi! PHP server var chalto aani browser la fakt HTML milto – mhanun "View Source" madhe PHP code disat nahi. Jar PHP code browser madhe disla, tar server PHP chalvat nahiye – te configuration chuk aahe.
Practice task
Draw the request flow for a static page and for a PHP page, labelling the port or socket at each arrow.