• Advertisement

• Popular Now

• 13
• 16
• 27
• 9
• 9
• Advertisement
• Advertisement
• Advertisement

[web] Set location of php.ini in httpd.conf

This topic is 2924 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm ready to tear my hair out. I'm on Slackware 13, trying to set up a local Apache server for trying out different web technologies and configurations. I've got PHP running, but to avoid running as root all the time, I need to specify a php.ini file owned by my regular user. But I can't figure out how to tell Apache to tell PHP to look for php.ini in my personal site directory. If this is possible (and it seems crazy to think that it isn't), how do you do it?

Share this post

Share on other sites
Advertisement
Of course now I find it... You have to set the PHPRC environment variable, where PHP looks for php.ini, in your httpd.conf using the SetEnv directive.
SetEnv PHPRC /path/to/config_file

Also, it seems running httpd ... -k restart doesn't clear all environment variables, so I had to completely stop it to see the effect.

Share this post

Share on other sites
You can use the PHPIniDir "/home/theocelot/php.ini" directive in your httpd.conf.

Share this post

Share on other sites
Thanks, that works too, and is clearer. [smile]

But even knowing what it's called, it's difficult to find clear documentation on it, and almost every time it's mentioned, it's in the context of a Windows installation. When you google just "phpinidir", the first thing to come up is a mostly incoherent thread on bytes.com. It would be easy to believe it was only for Windows.

Share this post

Share on other sites

• Advertisement