Rockstable Wiki:

php7-fpm

Installation

   1 aptitude install apache2 libapache2-mod-fastcgi php7.0 php7-fpm

Configure php7-fpm

/etc/php/7.0/fpm/pool.d/www.conf

   1 
   2 ;listen = /run/php/php7.0-fpm.sock
   3 listen = 127.0.0.1:9000
   4 

   1 root@puls:/etc/php/7.0/fpm/pool.d# cat /etc/apache2/conf-available/php7.0-fpm.conf
   2 # Redirect to local php-fpm if mod_php is not available
   3 <IfModule !mod_php7.c>
   4     # Enable http authorization headers
   5     SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
   6 
   7     #<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
   8     #    SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost:9000"
   9     #</FilesMatch>
  10     <FilesMatch ".+\.phps$">
  11         # Deny access to raw php sources by default
  12         # To re-enable it's recommended to enable access to the files
  13         # only in specific virtual host or directory
  14         Require all denied
  15     </FilesMatch>
  16     # Deny access to files without filename (e.g. '.php')
  17     <FilesMatch "^\.ph(p[3457]?|t|tml|ps)$">
  18         Require all denied
  19     </FilesMatch>
  20 </IfModule>

Configure fastcgi

   1 root@puls:/etc/php/7.0/fpm/pool.d# cat /etc/apache2/mods-available/fastcgi.conf
   2 <IfModule mod_fastcgi.c>
   3         AddHandler fastcgi-script .fcgi
   4         #FastCgiWrapper /usr/lib/apache2/suexec
   5         FastCgiIpcDir /var/lib/apache2/fastcgi
   6 
   7         AddHandler              php7-fcgi       .php
   8         Action                  php7-fcgi       /php7-fcgi
   9         Alias                   /php7-fcgi      /usr/lib/cgi-bin/php7-fcgi
  10         #FastCgiExternalServer  php5-fpm_www-mail -host 127.0.0.1:9000 -pass-header Authorization
  11         FastCgiExternalServer   /usr/lib/cgi-bin/php7-fcgi -host 127.0.0.1:9000 -pass-header Authorization
  12         #FastCgiExternalServer  /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php5-fpm_www-mail.sock -pass-header Authorization
  13         #FastCgiExternalServer  /usr/lib/cgi-bin/php7-fcgi -socket /var/lib/apache2/fastcgi/php5-fpm_www-mail.sock -pass-header Authorization
  14 </IfModule>

Enable Subsystems

Enable necessary modules

   1 root@puls:/etc/php/7.0/fpm/pool.d# a2enmod cgid fastcgi actions
   2 Enabling module cgid.
   3 Enabling module fastcgi.
   4 Enabling module actions.
   5 To activate the new configuration, you need to run:
   6   service apache2 restart

   1 root@puls:/etc/php/7.0/fpm/pool.d# cat /etc/apache2/conf-available/serve-cgi-bin.conf
   2 <IfModule mod_alias.c>
   3         <IfModule mod_cgi.c>
   4                 Define ENABLE_USR_LIB_CGI_BIN
   5         </IfModule>
   6 
   7         <IfModule mod_cgid.c>
   8                 Define ENABLE_USR_LIB_CGI_BIN
   9         </IfModule>
  10 
  11         <IfDefine ENABLE_USR_LIB_CGI_BIN>
  12                 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  13                 <Directory "/usr/lib/cgi-bin">
  14                         AllowOverride None
  15                         Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
  16                         Require all granted
  17                 </Directory>
  18         </IfDefine>
  19 </IfModule>
  20 
  21 # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
  22 

Enable necessary configuration

   1 root@puls:/etc/php/7.0/fpm/pool.d# a2enconf serve-cgi-bin php7.0-fpm
   2 Enabling conf serve-cgi-bin.
   3 Enabling conf php7.0-fpm.
   4 To activate the new configuration, you need to run:
   5   service apache2 reload

   1 root@puls:/etc/php/7.0/fpm/pool.d# a2dismod mpm_prefork 
   2 Module mpm_prefork disabled.
   3 To activate the new configuration, you need to run:
   4   service apache2 restart
   5 root@puls:/etc/php/7.0/fpm/pool.d# a2enmod mpm_event 
   6 Considering conflict mpm_worker for mpm_event:
   7 Considering conflict mpm_prefork for mpm_event:
   8 Enabling module mpm_event.
   9 To activate the new configuration, you need to run:
  10   service apache2 restart
  11 root@puls:/etc/php/7.0/fpm/pool.d#   service apache2 restart

Rockstable Wiki: php7-fpm (last edited 2020-05-26 17:23:04 by RockStable)