LAMP web server installation (Linux, Apache, MySQL, PHP) with PHP FPM

PHP FPM (FastCGI Process Manager) is a PHP process manager allowing to execute PHP code and is called via FastCGI by your webserver. It affords to your webserver to communicate with PHP and generally provides better performances. The purpose is to make PHP work in a separated way and to install the Apache FastCGI module in order to make Apache and PHP communicate.

Apache installation

At first, it is important to install Apache on the machine in question via the following command :

MySQL installation

Then, you need to install MySQL via the following command :

During the installation, you will be asked to choose a password root.

It is advised to carefully choose your password preferably alphanumeric and including special characters.

To continue with the installation, the following command must be executed :

Enter your password root when requested and confirm the four following questions with yes :

PHP-FPM installation

Finally, you need to install PHP-FPM :

So that Apache could join PHP-FPM, we install the Fast-CGI module :

PHP-FPM configuration

From then on, you have access to the PHP configuration :

Configuration folder for PHP from the command line.

Configuration folder for PHP-FPM.

Different modules folder installed for PHP, we will come back to it for the PHP module installation.

The configuration changes are operated by the file editing php.ini.

However, please notice that the default configuration is quite enough.
After any modification, you need to restart PHP-FPM :

Apache configuration in FastCGI

PHP-FPM is currently operational but Apache now needs to know how to interpret the PHP code.
The fastcgi module has to change according to the following way :

Now, we activate the Actions module and restart Apache :

The PHP-FPM installation and configuration is complete, each PHP (.php) file will be processed by PHP-FPM.

PHP modules installation

It may happen that your system doest not have libraries/modules yet which you could need for your developer, yet you can still add some others such as GD for a PHP image processing :

The modules installed are automatically activated and the respective configuration files are located in the /etc/php5/conf.d/ folder which returns to the /etc/php5/fpm/mods-available/ folder previously discussed.