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