Set path to php.ini

Is it possible to have only one php.ini file, for example, in webroot (or even outside it so that people cannot access it via GET) and quickly and easily tell PHP where it is?

I know that you can install php.ini directives in .htaccess, but is it possible to determine the specific php.ini file that will be used?

+5
source share
3 answers

Add this to your server configuration ...

<VirtualHost 1.2.3.4:80>
PHPINIDir /path/to/new/php_ini
</VirtualHost>

Be sure to specify the path to the directory, and not the entire path to the file.

Then restart Apache.

Check that it works with phpinfo().

+9
source

Take a look . user.ini in php docs.

PHP 5.3.0, PHP INI .htaccess. .

.unser.ini ini " , inini". ini . zzz , . .

+3

, , , -, suPHP. - - PHPINIDir , suPHP_ConfigPath.

mod_rewrite DOCROOT/.htaccess:

RewriteEngine   On
RewriteBase     /
# if a forbidden directory or file name (starting with a . or /) then raise 404 Fatal
RewriteRule (^|/)[_.] -         [F]

This prohibits any request for any file or directory name prefixed with .or _. I have DOCROOT/_privatewhere I keep this stuff for me:

suPHP_ConfigPath DOCROOT/_private

where you will need to replace DOCROOT with the local settings of your service. Find DOCUMENT_ROOT in the list phpinfo().

0
source

All Articles