example42 / puppet-php

A puppet module for php. According to Example42 NextGen spec.
Other
45 stars 62 forks source link

Has the PHP 5 config directory changed structure? #37

Closed tomphp closed 10 years ago

tomphp commented 11 years ago

Hi

I'm using the Ubuntu Precise 64bit box from vagrantup.com (http://files.vagrantup.com/precise64.box) and I'm using puppet-php I've got PHP installed and setup via the ppa:ondrej/php5 repository (version installed is 5.5.4+dfsg-1+debphp.org~precise+1).

However there's a problem copying the apache2 php.ini template into places. Looking at the error message and the ini.pp file, puppet-php is trying to copy the ini settings to /etc/php5/conf.d but that doesn't exist. And according to phpinfo() apache is using the ini file in /etc/php5/apache2/conf.d.

I've looked on a my own ubuntu 13.04 install and /etc/php5/conf.d exists and /etc/php5/apache2/conf.d is a symlink to it. However on my vagrant box /etc/php5/conf.d doesn't exist and /etc/php5/apache2/conf.d is a real folder containing symlinks to the module configs.

I've currently fixed it by editing puppet-php's ini.pp file and telling it to copy to the apache2 directory instead but I'm wandering is there a better way I can do this without hacking the puppet-php module (i.e. in my own puppet file) or any ideas why the /etc/php5 folder structure is different? Has it changed in new versions of PHP?

I suppose one option would be moving the folder and symlinking it in my puppet script, is that the best solution?

Thanks, Tom

alvagante commented 11 years ago

To keep track, in module, of distro changes of paths, names and so on is always a pain, that's why contributions like this are welcomed. The module should place the files where the distro expects them so any fix in params.pp to adapt to new versions or fix existing ones is good. The case of php is a bit more complex since some distros, like Ubuntu, have started to have (don't know when they began) 2 different php files for php when used from the cli or via apache. The php module currently doesn't manage this case so some more changes are needed. Any suggestion on the saner way is welcomed, a quick possible patch is to use as config_file path the one for apache (which sounds somehow arbitrary)... or, maybe better, keep the current one and force the creation of symlinks (if the php.ini is managed via Puppet) in the cli and httpd paths. Asking for opinions also to @davids @lermit @javierbertoli @Freeaqingme

tomphp commented 11 years ago

Thanks for your speedy reply, I will try and have a little think about it. Off the top of my head; regardless of whether the /etc/php5/apache2/conf.d folder is a symlink or a real directory, putting the ini file there would get it into the right place anyway. Saying that I'm not sure if that would break an BC for anyone using distros where there's only a /etc/php5/conf.d available.

One thing I can think of which maybe be a bit of a kludge but how about searching the /etc/php5 tree and copying it into every conf.d directory in there. I think it would be pretty safe atm but who knows what it could break in the future.

A better solution would be to find it out but it would require some dependencies, you could create a phpinfo file in the apache docroot and curl it, then grep out the ini location. Obviously that would be much more involved but then you'd know for sure.

I'm very new to puppet but I could have a crack at these solutions if I can find a bit of spare time (might not be for a little while as very busy atm)?

javierbertoli commented 11 years ago

The case of php is a bit more complex since some distros, like Ubuntu, have started to have (don't know when they began) 2 different php files for php when used from the cli or via apache.

The reason is that php can be used, as many other scripting languages, for day to day work, and sometimes you need different configurations for it depending the way you are going to run it. Ie, you may want longer values for "max input time", or "max execution time" when running in the CLI, while you don't want that for your apache module. The same goes for extensions, and so on.

Symlinking is probably a bad idea, as they all might differ. AFAIK, there are not that many options to keep if we want to add the paths in the params file:

{cli,http}/[conf.d]

so it would end up being, in params.pp:

$conf_dir = '/etc/php5'

$cli_conf_dir = "${conf_dir}/cli"
$cli_extensions_dir = "{$cli_conf_dir}/conf.d"
$http_conf_dir = "${conf_dir}/apache2"
$http_extensions_dir = "{$http_conf_dir}/conf.d"

As these would need to be sanitized in init.pp, there's some work to do to keep them right. The other way I can think of is just keeping these in params.pp:

$conf_dir = '/etc/php5'

$cli_subdir = 'cli'
$http_subdir = 'apache2'
$extensions_subdir = 'conf.d'

and assemble them as needed in the other recipes? Like:

$cli_extensions_subdir = "${php::conf_dir}/${php::cli_subdir}/${php::extensions_subdir}"
tomphp commented 11 years ago

Having more extensive params like @javierbertoli has suggested seems like a good idea to me :)

Freeaqingme commented 11 years ago

It's been a while that I've used the php module, will do so again in a couple of months probably.

I'm not sure if adding the extra params is the way to go. Without having given it too much thought, I'd suggest to implement an iptables::instance type, that can simply be defined N types. If someone would want to run an additional number of php instances, he/she could do so easily (not uncommon with nginx+fpm setups, where also different versions may be invoked).

DavidS commented 10 years ago

Yeah, support for running different fpm instances would be great. OTOH a proper default install should "know" which default instances exist (php-cli vs. php-cgi, etc) and configure them automatically and consistently, perhaps with one top level param to choose cgi or mod-php integration into apache and/or a pair of separate integration classes.

alvagante commented 10 years ago

I tried and evaluated different options, then simply decided to default the php.ini path to the apache2 dir, explaining in the README how to manage alternatives: