php.ini不会在public_html目录之外工作

Just very quick question about php.ini file. I created my own on my php.ini file and it works fine if I put it inside my 'public_html' directory. However the problem is it can obviously be viewed in browser through HTTP requests.

So, I am trying to move it outside my 'public_html' directory however it does not seem to work when outside my 'public_html'.

I know I could perhaps set in my .htaccess the following to avoid it being read:

<Files php.ini>
  Order allow,deny
  Deny from all
</Files>

However I do not want to do this as my php.ini can still get cached by Google if it's in the 'public_html' directory. Is there any suggestions to make it work outside my public_html?

I am running an Apache server. Thanks for any suggestions

It can't get cached by google if you block like that in .htaccess

You can use the PHPRC environment variable...see the documentation:

http://www.php.net/manual/en/configuration.file.php

Two suggestions:

  1. Ensure that Apache can find your php.ini (PHPINIDIR /path/where/php.ini/is/located)
  2. Ensure the file is readable by the webserver user.

How is it that you php.ini came to be in a web server accessible folder? It is the first time I hear of such a situation.

I thought hard on how you managed to do this, and the only answer I came up with is that you created a vhost in php folder. If that is the case, create another vhost out of the php.ini path, and remove the offending vhost. See this post for examples.