Using apache configuration to specify PHP include directory for each site

I recently switched to fastcgi, and now I have a problem setting the php enable path, which was previously installed in .htaccess as:

php_value include_path "[INCLUDE PATH]"

Since it is a switch, this gives an error:

Invalid php_value command, possibly with an error or determined by the module is not included in the server configuration

And for my understanding, "php_value" cannot be set via htaccess with fastcgi.

Is there a way around this or globally specify the path to enable php for the entire site with subdirectories, for example, through the apache configuration?

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

+4
source share
1 answer

You are out of luck, since only the PHP module supports directives php_valueand php_flag.

What you can do is create a file php.inifor each website. From memory, you will need the full file php.ini, since the new file will completely override the system file.

- , ,

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

.htaccess PHPRC. , php.ini .

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

, include_path . .

set_include_path(implode(PATH_SEPARATOR, [
    '[INCLUDE_PATH'],
    get_include_path()
]));
+2

All Articles