Not logged in - Login

Linux - Install Mod-FastCGI and PHP5-FPM on Ubuntu

Install Mod-FastCGI and PHP5-FPM on Ubuntu

Installation:

$ sudo apt-get install apache2-mpm-worker libapache2-mod-fastcgi php5-fpm $ sudo a2enmod actions alias fastcgi

Configuration:

edit /etc/apache2/mods-enabled/fastcgi.conf:

 AddHandler php5-fcgi .php  
 Action php5-fcgi /php5-fcgi  
 Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi  
 FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization

Restart Apache2 and PHP5-FPM

$ sudo service apache2 restart && sudo service php5-fpm restart

– Updated 2014-01-09 (Ubuntu 13.10)–

mkdir /var/www/cgi-bin

touch /var/www/cgi-bin/php5.fcgi

chown -R www-data:www-data /var/www/cgi-bin

edit /etc/apache2/mods-enabled/fastcgi.conf:

 <IfModule mod_fastcgi.c>
    AddHandler fastcgi-script .fcgi
    #FastCgiWrapper /usr/lib/apache2/suexec
    FastCgiIpcDir /var/lib/apache2/fastcgi

    Alias /php5.fcgi /var/www/cgi-bin/php5.fcgi
    AddType application/x-httpd-fastphp5 .php
    Action application/x-httpd-fastphp5 /php5.fcgi

    FastCGIExternalServer /var/www/cgi-bin/php5.fcgi -socket /var/run/php5-fpm.sock

    <Directory "/var/www/cgi-bin">
       Order allow,deny
       <Files "php5.fcgi">
          Order deny,allow
       </Files>
    </Directory>

 </IfModule>

Virtual host setting example :

<VirtualHost *:80>
   # Admin email, Server Name (domain name), and any aliases
   ServerAdmin webmaster@email.com
   ServerName  www.example.com
   # ServerAlias example.com

   # Index file and Document Root (where the public files are located)
   DirectoryIndex index.php index.html index.htm
   DocumentRoot /var/www/example
   <Directory /var/www/example>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride all
      Order allow,deny
      Allow from all
      Require all granted
   </Directory>

    # Log file locations
    LogLevel warn
    ErrorLog  ${APACHE_LOG_DIR}/error.example.com.log
    CustomLog ${APACHE_LOG_DIR}/access.example.com.log combined

</VirtualHost>

For more information:
http://blog.starcklin.com/2013/08/install-mod-fastcgi-and-php5-fpm-on-ubuntu/