Install and Configure PHP5-FPM With Apache2 On Ubuntu 14.04
In this tutorial we will discuss about installation and configuration of PHP5-FPM With Apache2 On Ubuntu 14.04.I using ubuntu 14.0.4 and my system hostname is host1.howtoistart.com with the IP address 192.168.0.200. These settings might be different for you, so you have to replace them where appropriate.
I’m running all these steps in this tutorial with root privileges, so make sure you switch your user to as root before moving further.
1. First of all, install Mysql server using the below given command:
First of all you will be asked for a password and after you provide a password for the MySQL root user, it will be valid for the user root@localhost as well as host1.howtoistart.com , so we don’t have to specify a MySQL root password manually later on:
2. Apache2 is available as an Ubuntu package. Now we will be required the apache2-mpm-worker package which we can install as given below:
Now direct type on your browser to http://192.168.0.200, and you should see the Apache2 default working page ( Apache2 Ubuntu Default Page. It works!).
Default document root is /var/www/html on Ubuntu, and the configuration file for the same is /etc/apache2/apache2.conf. Additional configurations are also available and are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules),/etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.
3. We can make PHP5 work in Apache2 through PHP-FPM and Apache’s mod_fastcgi module which we install as given below:
Note: PHP-FPM is a daemon process (with the init script /etc/init.d/php5-fpm) that runs a FastCGI server on port 9000.
In the next step, please enable Apache modules following the below command:
To make Apache work with PHP-FPM, we will be required the following configuration:
Apache 2.2 or earlier
Apache 2.4 or later
You can put it in the global Apache configuration (so it’s enabled for all vhosts), for e.g. you can put it in /etc/apache2/conf.d/php5-fpm.conf (this file does not exist, so you must create it), or you can place it in each vhost that should use PHP-FPM. I want to use PHP-FPM with the default vhost so I open its vhost configuration file /etc/apache2/sites-available/000-default.conf
Now put the following given section somewhere between :
For implementation in server, it will be required to restart Apache and php-fpm too using the commands given below:
For php-fpm integration with MySQL to get MySQL support in PHP, we can install the php5-mysql package. It’s a good idea to install some other PHP5 modules as well and you can search for available PHP5 modules as below:
Pick the ones you need and continue with their installation like this:
Making PHP-FPM Use A Unix Socket
By default PHP-FPM is listening on port:9000 on 127.0.0.1. We can make PHP-FPM use a Unix socket which avoids the TCP overhead and to do this, please open/etc/php5/fpm/pool.d/www.conf…
Apache Module mod_fastcgi: http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html
Now we successfully Install and Configure PHP5-FPM With Apache2 On Ubuntu 14.04.