helices Posted June 24, 2013 Share Posted June 24, 2013 (edited) I have inherited ( 8 ) servers on an intranet using various versions of php as main programming language. Most of these are not web servers. I've been tasked to consolidate and standardize on one (1) php.ini configuration file to be used on all ( 8 ) servers Some of these use odd locations for php.ini For example, a Solaris 10 host uses this configuration file: /usr/local/php-5.2.17/lib/php.ini # /usr/bin/php --info | grep -i php\.iniConfiguration File (php.ini) Path => /usr/local/php-5.2.17/libLoaded Configuration File => /usr/local/php-5.2.17/lib/php.ini # php-config | grep -i ini # php-config | grep -i with-config-file-path [ NO compile time options returned ... ] NONE of the user accounts running php have PHPRC set. Current working directory is whatever directory the user is in at execution time One thing that I need to do is get ALL of these servers using /etc/php.ini - even if that is a symbolic link How can I accomplish this standardization of /etc/php.ini? Please, advise. Thank you. Edited June 24, 2013 by helices Quote Link to comment https://forums.phpfreaks.com/topic/279523-how-to-standardize-php-configuration-files/ Share on other sites More sharing options...
requinix Posted June 24, 2013 Share Posted June 24, 2013 1. One php.ini means one PHP version too. At the very least the same major+minor (eg, 5.2.x). So there's that. 2. Then figure out what the various installations need. Find a common denominator. 3. Test. And yes, you can symlink /etc/php.ini to wherever the actual file is. Quote Link to comment https://forums.phpfreaks.com/topic/279523-how-to-standardize-php-configuration-files/#findComment-1437702 Share on other sites More sharing options...
helices Posted June 24, 2013 Author Share Posted June 24, 2013 Thank you; but, that's not my problem here. The example installation is looking here: /usr/local/php-5.2.17/lib/php.ini HOW can I get that instance to always look here: /etc/php.ini ??? NO, I cannot do: php -c path|file -NOR- php --php-ini path|file Yes, I can make a symbolic link; but, I'm looking to understand HOW this example installation knows to look here: /usr/local/php-5.2.17/lib/php.ini When I understand why it's looking there, then I will know what to do in other cases. The manual appears to be incorrect when it states: php.ini is searched for in these locations (in order): SAPI module specific location (PHPIniDir directive in Apache 2, -c command line option in CGI and CLI, php_ini parameter in NSAPI, PHP_INI_PATH environment variable in THTTPD) The PHPRC environment variable. Before PHP 5.2.0, this was checked after the registry key mentioned below. As of PHP 5.2.0, the location of the php.ini file can be set for different versions of PHP. The following registry keys are examined in order: [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z], [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y] and [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x], where x, y and z mean the PHP major, minor and release versions. If there is a value for IniFilePath in any of these keys, the first one found will be used as the location of the php.ini (Windows only). [HKEY_LOCAL_MACHINE\SOFTWARE\PHP], value of IniFilePath (Windows only). Current working directory (except CLI). The web server's directory (for SAPI modules), or directory of PHP (otherwise in Windows). Windows directory (C:\windows or C:\winnt) (for Windows), or --with-config-file-path compile time option. Quote Link to comment https://forums.phpfreaks.com/topic/279523-how-to-standardize-php-configuration-files/#findComment-1437706 Share on other sites More sharing options...
kicken Posted June 24, 2013 Share Posted June 24, 2013 If you compile your own PHP, the I'd imagine you could just used the configure option to set the path. If you want to use the version from the system's package management tools, then probably you'd just have to symlink the location it stores the ini file in to /etc/php.ini I would store the actual php.ini file in /etc/php.ini in all cases, and then if necessary, symlink the necessary location to that. Eg /usr/local/php-5.2.17/lib/php.ini would be the symlink which points to /etc/php.ini From a CLI perspective, another potential option would be to replace the php binary with a shell script which sets the PHPRC env var then runs php, eg: #!/bin/bash PHPRC=/etc export PHPRC # assuming you rename the php binary to __php exec /usr/bin/__php "$@" Quote Link to comment https://forums.phpfreaks.com/topic/279523-how-to-standardize-php-configuration-files/#findComment-1437722 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.