Forcing a domain to use a specific php.ini

How, on a dedicated server, can you force the domain to use a particular php.ini? I’ve put SetEnv PHPRC /home/username/public_html/php.ini into the .htaccess file, but when I change the php.ini the domain doesn’t reflect that change? How do you do it please?

If it’s a dedicated server, you shouldnt need to do this? I dont quite understand your intent. Also on a dedicated server why would you have /home/username/public_html? That would be…not a dedicated server.

Furthermore, what Server API mode is PHP running in? What ini variables are you trying to override?

Answers from the hosts:

The server is set to use FastCGI for performance

FastCGI allows better security than the native SuPHP

Also FastCGI permits cache to which your using APC. SuPHP can not handle cache.

So which php.ini settings are you attempting to override, and are you doing it in accordance with the Manual’s Description on Per User INI?

Sorry, I’m getting out of my depth on this.

The reason shared hosts don’t give access to the ini is because a poorly made setting could affect others on the “share”.

I have used ini_get / ini_set before.
Can the setting you are interested in tweaking be changed that way?

This is on a dedicated server.

Where/how do I put ini_get / ini_set please?

I do it in individual files “as needed”.

For example, say a script needs longer to run,
I have used ini_get() to assign the value to a variable.
Then I used ini_set() to tweak it up to what I need
Then after the script has run, I’ve used ini_set() and to reset it to the original value using the variable from the ini_get

I guess I haven’t needed to do it in a while or more likely missed seeing the ini_restore() function, but it looks to be a better way that what I’ve done in my older code.

Trying to do it, so that it applies to all pages in one domain. The hosts are saying that I’m on FastCGI and it can’t work with customised php.ini files?

If you run this simple file do you not see an array of settings?

<?php
echo '<pre>';
var_dump(ini_get_all());
echo '</pre>';
?>

I’m not personally familiar with fast cgi but AFAIK you should be able to change some at run time

http://php.net/manual/en/configuration.changes.php

Regardless of how you run PHP, you can change certain values at runtime of your scripts through ini_set(). See the documentation on the ini_set() page for more information.

Thanks Mittineague, where do I put that code please?

Just create a whatever-name “.php” file with only that code in it
upload to your server
go to it in your browser
copy the info for later reference
remove the file from your server

The reason the last step in post #12 is
remove the file from your server

is so that no one would be able to see your settings and look for, a maybe see, a security vulnerability.

Step #4 was
copy the info for later reference
not post it here

Please Delete those posts ASAP

Okay. Thanks. Does/did it all look okay to you?

The direction I was going was not whether or not the settings were OK, but
Is the setting(s) you are wanting to change included in that array?

If so, then you should be able to use ini_set in your code.

Thanks, what precise code am I looking for in those results please?

That depends on which settings are you wanting to change. i.e.
What code are you wanting to run that is having problems because of default setting values?

In my limited experience the settings I’ve needed to tweak are

  • associated with time limits
  • associated with file size restrictions
  • timezone

But I don’t know what you’re wanting to do and having trouble doing.

I was trying to force a domain to use a particular php.ini, but was told by the hosts, that it couldn’t be done in fastcgi, so there’s now been a change to suphp.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.