4

I'm using Puppetlabs/Apache to configure Apache. In the main puppet file, I call and configure it:

class { '::apache': }
class { '::apache::mod::fastcgi': }
apache::vhost { "${::fqdn} non-ssl":
    servername      => $::fqdn,
    port            => '2222',
    docroot         => "/var/www/${root}",
    priority        => 10,
}

The apache::mod::fastcgi manifest works seamlessly ... with one drawback: PHP somehow still runs on (cli) mode:

vagrant@wp:/etc/apache2/mods-enabled$ php -v
PHP 5.5.12-1+deb.sury.org~precise+1 (cli) (built: May  8 2014 21:04:38)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

To confirm that, I added a phpinfo() call to the a phpinfo.php file and checked php /path/to/phpinfo.php | less and Service API still is at cli.

When I look into /etc/apache2/mods-enabled, I can see fastcgi.conf and fastcgi.load. I checked the contents sudo nano fastcgi.conf/load - which comes from the fastcgi.conf.erb template from the module:

# ===> fastcgi.conf
# The Fastcgi Apache module configuration file is being
# managed by Puppet and changes will be overwritten.
<IfModule mod_fastcgi.c>
  AddHandler fastcgi-script .fcgi
  FastCgiIpcDir "/var/lib/apache2/fastcgi"
</IfModule>

# ===> fastcgi.load
adModule fastcgi_module /usr/lib/apache2/modules/mod_fastcgi.so

Note: There is a vhosts.erb template as well, which has a subtemplate _fastcgi.erb that builds the FastCGI block for the vhosts template.

When I try to set it up (which puppetlabs/apache::mod::fastcgi should already have done) with sudo a2enmod fastcgi alias, I get the following answer (on the CLI):

Module fastcgi already enabled
Module alias already enabled

And when I check /etc/apache2/sites-enabled contents with sudo nano 15-default.conf, I see the following:

<VirtualHost *:80>
  # ...

  ## Script alias directives
  ScriptAlias /cgi-bin/ "/usr/lib/cgi-bin"
</VirtualHost>

I switched then to the root/main user with sudo su and checked the directory that is referenced in the fastcgi.conf file: /var/lib/apache2/fastcgi. It only has one content: An empty folder named dynamic. Could this be the source of the problem: An empty FastCGI lib?

I can't really get behind how FastCGI can be enabled and running, but still reading that cli is the mode I'm running PHP on.

Edit 1

I just checked if php-fpm is running:

vagrant@wp:/etc/apache2/conf.d$ ps -ef | grep php-fpm
root       935     1  0 15:58 ?        00:00:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
www-data   982   935  0 15:58 ?        00:00:00 php-fpm: pool www
www-data   983   935  0 15:58 ?        00:00:00 php-fpm: pool www
vagrant   2760  2605  0 19:40 pts/2    00:00:00 grep --color=auto php-fpm

I also restarted php5-fpm and apache2 services manually, but with the same result

sudo service php5-fpm restart
sudo service apache2 restart
php -v
# still: (cli)

If I would know what is missing, I could manually rewrite the httpd.conf.erb template or just pull in those pieces that are missing and use the default puppetlabs/apache templates - as this is an option for the module. The same goes for '/etc/apache2/mods-available' or the '/etc/apache2/sites-available' dir

kaiser
  • 1,251
  • 1
  • 16
  • 24

1 Answers1

1

First: if you you exec php -v on the shell, you'll always get the cli version. Because you're on the command line interface...

how did you install your php-fpm module? which mode did you use? (tcp or sock?) did you already configure a vhost? => not the default one - please check sites-enabled directory, there should be a file with $fqdn ($fqdn means your fully qualified domain name like example.com)

with apache 2.4 and mod_proxy_fcgi you can easily pass .php requests to your FPM pool over the vhost config:

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/path/to/your/documentroot/$1

=> check your vhost if there is such a directive

  • Just to note that: I did not really install anything - it was Puppet (the provisioner I use) doing that. I linked to most of the scripts in the question. – kaiser Jun 04 '14 at 12:31