7

I’m new to system administration and while launching oho files with Apache 2 server I had to install php on my Ubuntu 16.04.

I tried the basic sudo apt-get install php, which only loaded a blank page (php file).

But installing libapache2_mod_php solved my problem.

I want to understand the differences .

logi-kal
  • 7,107
  • 6
  • 31
  • 43
Deeraj Theepshi
  • 183
  • 3
  • 10
  • `php` is just a binary that can execute php code, much like `java`. `libapache2_mod_php` is a php binary that is designed and compiled to work with the Apache webserver, so that Apache that interpret php and handle it. Apache can't know if you have a php binary unless you give it the very specific instructions that you have: insert `libapache2_mod_php` – Loek Jun 08 '18 at 10:23

2 Answers2

17

It's pretty simple: Apache is WWW Server, PHP - a interpretter. By libapache2_mod_php library, the Apache can send request to the PHP, which builts website, sends rendered HTML (or whatever else) to the Apache, and it is later responsed to the user.

The flow is something like that: enter image description here

without that library, the Apache don't know what is .php file, and recognizes it like raw file which can be downloaded, without being interpreted by PHP (sometimes it's very dangerous, for example when you are storing passwords in PHP file).

Siper
  • 1,175
  • 1
  • 14
  • 39
6

libapache2_mod_php is the plugin in Apache webserver that interprets .php files (and others, depends on how you configure it) instead of serving the .php files as is (otherwise you would get the php code in your page).

The module is also a bit faster, since it runs within the Apache process rather than a separate executable each time the script needs to be interpreted. But they use the same underlying libraries.

jbx
  • 21,365
  • 18
  • 90
  • 144