configure apache2 on ubuntu 16.04 vps to use php-fpm is not leading to the desired outcome

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

configure apache2 on ubuntu 16.04 vps to use php-fpm is not leading to the desired outcome

Dino Vliet

Dear all,


I'm new here and not sure this place is where I can posts these questions but I have been trying to configure my Ubuntu 16.04 VPS to use PHP-FPM with Apache2.


I followed this source:

1. https://www.howtoforge.com/tutorial/apache-with-php-fpm-on-ubuntu-16-04/


Modified this file:

/etc/apache2/sites-available/000-default.conf to now have this inside:


 <Directory /usr/lib/cgi-bin>

  Require all granted

  </Directory>

  <IfModule mod_fastcgi.c>

  AddHandler php7-fcgi .php

  Action php7-fcgi /php7-fcgi virtual

  Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi

  FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php/php7.0-fpm.sock -pass-header Authorization

  </IfModule>


Also modified this file /etc/apache2/conf-available and now it contains


# Redirect to local php-fpm if mod_php is not available

<IfModule !mod_php7.c>

  # Enable http authorization headers

  SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1


  <FilesMatch ".+\.ph(p[3457]?|t|tml)$">

  SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"

  </FilesMatch>

  <FilesMatch ".+\.phps$">

  # Deny access to raw php sources by default

  # To re-enable it's recommended to enable access to the files

  # only in specific virtual host or directory

  Require all denied

  </FilesMatch>

  # Deny access to files without filename (e.g. '.php')

  <FilesMatch "^\.ph(p[3457]?|t|tml|ps)$">

  Require all denied

  </FilesMatch>

</IfModule>


However, when I look at the output of the info.php page I have created in the document root I see Server API --> Apache 2.0 Handler in stead of what I expected after fiddling with the configuration. I expected Server API --> FPM/FastCGI


What I find strange, is the contents of /run/php and the size of the php7.0-fpm.sock, the www-data and s in front of the directory but don't know if this has anything to do with it.


/run/php$ ls -l

total 4

-rw-r--r-- 1 root  root  4 Jul  3 02:18 php7.0-fpm.pid

srw-rw---- 1 www-data www-data 0 Jul  3 02:18 php7.0-fpm.sock


Command uname -a gives:

4.4.0-83-generic #106-Ubuntu SMP Mon Jun 26 17:54:43 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux


Command dpkg -l | grep apache gives

ii  apache2  2.4.18-2ubuntu3.3  amd64  Apache HTTP Server

ii  apache2-bin  2.4.18-2ubuntu3.3  amd64  Apache HTTP Server (modules and other binary files)

ii  apache2-data  2.4.18-2ubuntu3.3  all  Apache HTTP Server (common files)

ii  apache2-utils  2.4.18-2ubuntu3.3  amd64  Apache HTTP Server (utility programs for web servers)

ii  libapache2-mod-fastcgi  2.4.7~0910052141-1.2  amd64  Apache 2 FastCGI module for long-running CGI scripts

ii  libapache2-mod-php7.0  7.0.18-0ubuntu0.16.04.1  amd64  server-side, HTML-embedded scripting language (Apache 2 module)


Command dpkg -l | grep php gives:

ii  libapache2-mod-php7.0  7.0.18-0ubuntu0.16.04.1  amd64  server-side, HTML-embedded scripting language (Apache 2 module)

ii  php-common  1:35ubuntu6  all  Common files for PHP packages

ii  php-imagick  3.4.0~rc6-1ubuntu3  amd64  Provides a wrapper to the ImageMagick library

ii  php-pear  1:1.10.1+submodules+notgz-6  all  PEAR Base System

ii  php-xml  1:7.0+35ubuntu6  all  DOM, SimpleXML, WDDX, XML, and XSL module for PHP [default]

ii  php7.0  7.0.18-0ubuntu0.16.04.1  all  server-side, HTML-embedded scripting language (metapackage)

ii  php7.0-cli  7.0.18-0ubuntu0.16.04.1  amd64  command-line interpreter for the PHP scripting language

ii  php7.0-common  7.0.18-0ubuntu0.16.04.1  amd64  documentation, examples and common module for PHP

ii  php7.0-curl  7.0.18-0ubuntu0.16.04.1  amd64  CURL module for PHP

ii  php7.0-fpm  7.0.18-0ubuntu0.16.04.1  amd64  server-side, HTML-embedded scripting language (FPM-CGI binary)

ii  php7.0-gd  7.0.18-0ubuntu0.16.04.1  amd64  GD module for PHP

ii  php7.0-imap  7.0.18-0ubuntu0.16.04.1  amd64  IMAP module for PHP

ii  php7.0-intl  7.0.18-0ubuntu0.16.04.1  amd64  Internationalisation module for PHP

ii  php7.0-json  7.0.18-0ubuntu0.16.04.1  amd64  JSON module for PHP

ii  php7.0-mcrypt  7.0.18-0ubuntu0.16.04.1  amd64  libmcrypt module for PHP

ii  php7.0-mysql  7.0.18-0ubuntu0.16.04.1  amd64  MySQL module for PHP

ii  php7.0-opcache  7.0.18-0ubuntu0.16.04.1  amd64  Zend OpCache module for PHP

ii  php7.0-pspell  7.0.18-0ubuntu0.16.04.1  amd64  pspell module for PHP

ii  php7.0-readline  7.0.18-0ubuntu0.16.04.1  amd64  readline module for PHP

ii  php7.0-recode  7.0.18-0ubuntu0.16.04.1  amd64  recode module for PHP

ii  php7.0-snmp  7.0.18-0ubuntu0.16.04.1  amd64  SNMP module for PHP

ii  php7.0-sqlite3  7.0.18-0ubuntu0.16.04.1  amd64  SQLite3 module for PHP

ii  php7.0-tidy  7.0.18-0ubuntu0.16.04.1  amd64  tidy module for PHP

ii  php7.0-xml  7.0.18-0ubuntu0.16.04.1  amd64  DOM, SimpleXML, WDDX, XML, and XSL module for PHP

ii  php7.0-xmlrpc  7.0.18-0ubuntu0.16.04.1  amd64  XMLRPC-EPI module for PHP

ii  php7.0-xsl  7.0.18-0ubuntu0.16.04.1  all  XSL module for PHP (dummy)



What have I missed and what should I do to have apache2 run with FastCGI?


With kind regards,


Dino Vliet

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: configure apache2 on ubuntu 16.04 vps to use php-fpm is not leading to the desired outcome

John Iliffe
Try using the PHP5 version of php-fcgi.

Not sure what your problem might be but a few months ago I had a LOT of
trouble and couldn't get PHP7 php-fpm OR php-fcgi working so at the
suggestion of the PHP list I backed off to PHP5 and everything worked
exactly as expected.

Worth a try anyway!

John
=======================================
On Saturday 22 July 2017 19:32:05 Dino Vliet wrote:

> Dear all,
>
>
>
>
> I'm new here and notsure this place is where I can posts these questions
> but I have beentrying to configure my Ubuntu 16.04 VPS to use PHP-FPM
> with Apache2.
>
>
>
>
> I followed thissource:
>
> 1.https://www.howtoforge.com/tutorial/apache-with-php-fpm-on-ubuntu-16-0
> 4/
>
>
>
>
> Modified this file:
>
> /etc/apache2/sites-available/000-default.confto now have this inside:
>
>
>
>
>  <Directory/usr/lib/cgi-bin>
>
>   Require allgranted
>
>   </Directory>
>
>   <IfModulemod_fastcgi.c>
>
>   AddHandlerphp7-fcgi .php
>
>   Actionphp7-fcgi /php7-fcgi virtual
>
>   Alias/php7-fcgi /usr/lib/cgi-bin/php7-fcgi
>
>  FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi
> -socket/var/run/php/php7.0-fpm.sock -pass-header Authorization
>
>   </IfModule>
>
>
>
>
> Also modified thisfile /etc/apache2/conf-available and now it contains
>
>
>
>
> # Redirect to localphp-fpm if mod_php is not available
>
> <IfModule!mod_php7.c>
>
>   # Enable httpauthorization headers
>
>  SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
>
>
>
>
>   <FilesMatch".+\.ph(p[3457]?|t|tml)$">
>
>   SetHandler"proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"
>
>   </FilesMatch>
>
>   <FilesMatch".+\.phps$">
>
>   # Deny accessto raw php sources by default
>
>   # Tore-enable it's recommended to enable access to the files
>
>   # only inspecific virtual host or directory
>
>   Require alldenied
>
>   </FilesMatch>
>
>   # Deny accessto files without filename (e.g. '.php')
>
>   <FilesMatch"^\.ph(p[3457]?|t|tml|ps)$">
>
>   Require alldenied
>
>   </FilesMatch>
>
> </IfModule>
>
>
>
>
> However, when I lookat the output of the info.php page I have created in
> the documentroot I see Server API --> Apache 2.0 Handler in stead of
> what Iexpected after fiddling with the configuration. I expected Server
> API--> FPM/FastCGI
>
>
>
>
> What I find strange,is the contents of /run/php and the size of the
> php7.0-fpm.sock, thewww-data and s in front of the directory but don't
> know if this hasanything to do with it.
>
>
>
>
> /run/php$ ls -l
>
> total 4
>
> -rw-r--r-- 1 root root  4 Jul  3 02:18 php7.0-fpm.pid
>
> srw-rw---- 1www-data www-data 0 Jul  3 02:18 php7.0-fpm.sock
>
>
>
>
> Command uname -agives:
>
> 4.4.0-83-generic#106-Ubuntu SMP Mon Jun 26 17:54:43 UTC 2017 x86_64
> x86_64 x86_64GNU/Linux
>
>
>
>
> Command dpkg -l |grep apache gives
>
> ii  apache2 2.4.18-2ubuntu3.3  amd64  Apache HTTP Server
>
> ii apache2-bin  2.4.18-2ubuntu3.3  amd64  Apache HTTPServer (modules and
> other binary files)
>
> ii apache2-data  2.4.18-2ubuntu3.3  all  Apache HTTPServer (common
> files)
>
> ii apache2-utils  2.4.18-2ubuntu3.3  amd64  Apache HTTPServer (utility
> programs for web servers)
>
> ii libapache2-mod-fastcgi  2.4.7~0910052141-1.2  amd64 Apache 2 FastCGI
> module for long-running CGI scripts
>
> ii libapache2-mod-php7.0  7.0.18-0ubuntu0.16.04.1  amd64 server-side,
> HTML-embedded scripting language (Apache 2 module)
>
>
>
>
> Command dpkg -l |grep php gives:
>
> ii libapache2-mod-php7.0  7.0.18-0ubuntu0.16.04.1  amd64 server-side,
> HTML-embedded scripting language (Apache 2 module)
>
> ii  php-common 1:35ubuntu6  all  Common files for PHP packages
>
> ii php-imagick  3.4.0~rc6-1ubuntu3  amd64  Provides awrapper to the
> ImageMagick library
>
> ii  php-pear 1:1.10.1+submodules+notgz-6  all  PEAR Base System
>
> ii  php-xml 1:7.0+35ubuntu6  all  DOM, SimpleXML, WDDX, XML, and
> XSLmodule for PHP [default]
>
> ii  php7.0 7.0.18-0ubuntu0.16.04.1  all  server-side,
> HTML-embeddedscripting language (metapackage)
>
> ii  php7.0-cli 7.0.18-0ubuntu0.16.04.1  amd64  command-line
> interpreterfor the PHP scripting language
>
> ii php7.0-common  7.0.18-0ubuntu0.16.04.1  amd64 documentation, examples
> and common module for PHP
>
> ii php7.0-curl  7.0.18-0ubuntu0.16.04.1  amd64  CURLmodule for PHP
>
> ii  php7.0-fpm 7.0.18-0ubuntu0.16.04.1  amd64  server-side,
> HTML-embeddedscripting language (FPM-CGI binary)
>
> ii  php7.0-gd 7.0.18-0ubuntu0.16.04.1  amd64  GD module for PHP
>
> ii php7.0-imap  7.0.18-0ubuntu0.16.04.1  amd64  IMAPmodule for PHP
>
> ii php7.0-intl  7.0.18-0ubuntu0.16.04.1  amd64 Internationalisation
> module for PHP
>
> ii php7.0-json  7.0.18-0ubuntu0.16.04.1  amd64  JSONmodule for PHP
>
> ii php7.0-mcrypt  7.0.18-0ubuntu0.16.04.1  amd64 libmcrypt module for
> PHP
>
> ii php7.0-mysql  7.0.18-0ubuntu0.16.04.1  amd64  MySQLmodule for PHP
>
> ii php7.0-opcache  7.0.18-0ubuntu0.16.04.1  amd64  ZendOpCache module
> for PHP
>
> ii php7.0-pspell  7.0.18-0ubuntu0.16.04.1  amd64  pspellmodule for PHP
>
> ii php7.0-readline  7.0.18-0ubuntu0.16.04.1  amd64 readline module for
> PHP
>
> ii php7.0-recode  7.0.18-0ubuntu0.16.04.1  amd64  recodemodule for PHP
>
> ii php7.0-snmp  7.0.18-0ubuntu0.16.04.1  amd64  SNMPmodule for PHP
>
> ii php7.0-sqlite3  7.0.18-0ubuntu0.16.04.1  amd64 SQLite3 module for PHP
>
> ii php7.0-tidy  7.0.18-0ubuntu0.16.04.1  amd64  tidymodule for PHP
>
> ii  php7.0-xml 7.0.18-0ubuntu0.16.04.1  amd64  DOM, SimpleXML, WDDX,
> XML,and XSL module for PHP
>
> ii php7.0-xmlrpc  7.0.18-0ubuntu0.16.04.1  amd64 XMLRPC-EPI module for
> PHP
>
> ii  php7.0-xsl 7.0.18-0ubuntu0.16.04.1  all  XSL module for PHP (dummy)
>
>
>
>
>
>
>
> What have I missedand what should I do to have apache2 run with FastCGI?
>
>
>
>
> With kind regards,
>
>
>
>
> Dino Vliet

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: configure apache2 on ubuntu 16.04 vps to use php-fpm is not leading to the desired outcome

Luca Toscano
In reply to this post by Dino Vliet
Hi Dino,


2017-07-23 1:32 GMT+02:00 Dino Vliet <[hidden email]>:

Modified this file:

/etc/apache2/sites-available/000-default.conf to now have this inside:


 <Directory /usr/lib/cgi-bin>

  Require all granted

  </Directory>

  <IfModule mod_fastcgi.c>

  AddHandler php7-fcgi .php

  Action php7-fcgi /php7-fcgi virtual

  Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi

  FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php/php7.0-fpm.sock -pass-header Authorization

  </IfModule>


In here it seems that you are using mod_fastcgi (configured to not manage FCGI processes afaict)


Also modified this file /etc/apache2/conf-available and now it contains


# Redirect to local php-fpm if mod_php is not available

<IfModule !mod_php7.c>

  # Enable http authorization headers

  SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1


  <FilesMatch ".+\.ph(p[3457]?|t|tml)$">

  SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"

  </FilesMatch>


And in here mod_proxy_fcgi? Are you sure that this is what you wanted to achieve?
 

However, when I look at the output of the info.php page I have created in the document root I see Server API --> Apache 2.0 Handler in stead of what I expected after fiddling with the configuration. I expected Server API --> FPM/FastCGI


What have I missed and what should I do to have apache2 run with FastCGI?



Hope that helps!

Luca 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: configure apache2 on ubuntu 16.04 vps to use php-fpm is not leading to the desired outcome

Gillis J. de Nijs
I see you have libapache2-mod-php7.0 installed.  Are you sure you disabled it?  In Ubuntu you can use a2dismod to disable modules.  I suspect mod_php is listed there.  It's not required when you want to do fpm.

On Tue, Jul 25, 2017 at 10:02 AM, Luca Toscano <[hidden email]> wrote:
Hi Dino,


2017-07-23 1:32 GMT+02:00 Dino Vliet <[hidden email]>:

Modified this file:

/etc/apache2/sites-available/000-default.conf to now have this inside:


 <Directory /usr/lib/cgi-bin>

  Require all granted

  </Directory>

  <IfModule mod_fastcgi.c>

  AddHandler php7-fcgi .php

  Action php7-fcgi /php7-fcgi virtual

  Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi

  FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php/php7.0-fpm.sock -pass-header Authorization

  </IfModule>


In here it seems that you are using mod_fastcgi (configured to not manage FCGI processes afaict)


Also modified this file /etc/apache2/conf-available and now it contains


# Redirect to local php-fpm if mod_php is not available

<IfModule !mod_php7.c>

  # Enable http authorization headers

  SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1


  <FilesMatch ".+\.ph(p[3457]?|t|tml)$">

  SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"

  </FilesMatch>


And in here mod_proxy_fcgi? Are you sure that this is what you wanted to achieve?
 

However, when I look at the output of the info.php page I have created in the document root I see Server API --> Apache 2.0 Handler in stead of what I expected after fiddling with the configuration. I expected Server API --> FPM/FastCGI


What have I missed and what should I do to have apache2 run with FastCGI?



Hope that helps!

Luca 

Loading...