Question

I recently switched to fastcgi and now I have a problem with setting the php include path which had previously been set in .htaccess as:

php_value include_path "[INCLUDE PATH]"

Since the switch, this gives the error:

Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration

And to my understanding 'php_value' cannot be set via htaccess with fastcgi.

Are there any ways to get around this or to globally specify the php include path for a whole site with subdirectories, such as through the apache configuration?

I know that I can manually set the include path on each script in php or I can specify the include path in a php.ini in the directory, but the websites are already established with many files and directories and it would be cumbersome to go through each file and directory to copy the new include paths or php.ini files.

Was it helpful?

Solution

You're pretty much out of luck as only the PHP module supports the php_value and php_flag directives.

What you can do is create a php.ini file for each website. From memory, you will need this to be a full php.ini file as a new file will completely override the system one.

One simple way to do this would be copy the system file and then add your custom property, eg

cp /usr/share/php5/php.ini /path/to/site/php.d/php.ini \
&& echo 'include_path = "[INCLUDE PATH]"' >> /path/to/site/php.d/php.ini

Then, in the site's .htaccess file, set the PHPRC environment variable. This is to avoid having to add a php.ini file into every directory.

SetEnv PHPRC /path/to/site/php.d

Ideally though, each site should take care of its own include_path in code. This will make your applications much more portable.

set_include_path(implode(PATH_SEPARATOR, [
    '[INCLUDE_PATH'],
    get_include_path()
]));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top