setup LAMP server ubuntu 16.04 apache with php7.0-fpm

setup LAMP server ubuntu 16.04 apache with php7.0-fpm

vijay / June 20, 2017

Apache with mod php works well but it consumed lot of resource and hence also give problem of high server load average  when you are running a high traffic website of wordpress or drupal etc.

So here is the solution to overcome .

You can setup a ubuntu 16.04 server to work apache with mod event i.e. worker and with using php-fpm

We are using crazytechindia fresh KVM VPS of  ubuntu 16.04 64 bit installed .


Install required packages
# apt-get install php7.0-fpm apache2 libapache2-mod-fastcgi
Install php packages
# apt-get install php7.0-gd php7.0-mcrypt php7.0-curl php7.0-xml php7.0-pdo php7.0-mbstring php7.0-zip -y
disable mpm worker
# a2dismod mpm_worker
enable mpm event
# a2enmod mpm_event
enable required apache modules
# a2enmod alias rewrite fastcgi expires headers remoteip ssl actions
Create new file
# /etc/apache2/conf-available/php-fpm.conf
put the bellow content
<IfModule mod_fastcgi.c>
AddHandler php.fcgi .php
Action php.fcgi /php.fcgi
Alias /php.fcgi /usr/lib/cgi-bin/php.fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php.fcgi -socket /run/php/php7.0-fpm.sock -pass-header Authorization -idle-timeout 3600
<Directory /usr/lib/cgi-bin>
Require all granted
Now enable this configuration

# a2enconf php-fpm
Install google pagespeed module
# wget
# dpkg -i mod-pagespeed-*.deb
# apt-get -f install
# rm mod-pagespeed-*.deb
# systemctl restart apache2
Configure google pagespeed
# vim /etc/apache2/mods-available/pagespeed.conf

Turn on or off this module by
ModPagespeed on
Wnat to enable corefilters
ModPagespeedRewriteLevel CoreFilters
ModPagespeedRewriteLevel PassThrough

Using the default “CoreFilters” rewrite level includes a number of filters by default. As of the time of this writing, it includes:?


If you’d like to enable additional filters, you can pass them as a comma-separated list to

ModPagespeedEnableFilters pedantic,remove_comments

You can also disable filters on a per-case basis if you’d like. Specify a list of filters you’d like to disable similar to

ModPagespeedDisableFilters convert_jpeg_to_progressive


All done!


Advantages of Crazy Tech India NGINX VPS

Build a super fast website on super fast web server, Nginx fast cgi caching,and pagespeed enabled. KVM Virtualized VPS dedicated resource gauranteed, Free monitoring. Starts INR 749/M

@ 2017 Crazy Tech India -Web Hosting company