The possibilities of changing the PHP configuration for the user


Very often, the user needs to change the PHP settings one way or another to work with scripts. There are two possible options.


Case 1. It is necessary to make changes at the PHP compilation (assembly) level (adding modules, changing PHP_INI_SYSTEM system options).


Case 2. It is enough to change the value of one or more options that have the changeability status of PHP_INI_PERDIR or PHP_INI_ALL.


Recall the meaning and interpretation of the constants PHP_INI_*:

























PHP_INI_USER 1 The option can be set in user scripts
PHP_INI_PERDIR 2 The option can be set to php.ini, .htaccess or httpd.conf
PHP_INI_SYSTEM 4 The option can be set to php.ini or httpd.conf
PHP_INI_ALL 7 The option can be installed anywhere

 


In the first case , when we need to change the PHP configuration by adding new modules (imap, templates, curl), with which our modular PHP is not built. If so, you need to build your PHP. After the build, we recommend copying our INI file:


/usr/local/etc/php.ini

or


/usr/local/etc/php.ini

depending on the type of SAPI interface used (cgi or cli).


In the second case, when you do not need to use any additional modules, but only need to change the value of the directives managed in php.ini - you should simply copy the already assembled executable file php-SAPI to the site and perform the necessary actions with .htaccess:


/usr/local/bin/php-cgi

or


/usr/local/bin/php

depending on the type of SAPI interface used.


If the set values of the directives in our INI files match the desired ones, you do not need to copy the INI file. In particular, such actions are performed when it is necessary to increase the memory_limit value for PHP. If you plan to change the directives in php-SAPI.ini — it should be copied, similar to the method described above.


ls /usr/local/etc/php.ini | awk '{print $1}' | xargs grep memory_limit
/usr/local/etc/php.ini: memory_limit = 32M

Pay special attention to the fact that if, as a result of adding your directive, you received an error or did not get the desired result, then there is a possibility that configuring the corresponding parameter is simply not available at this level. If so, try to build your own PHP, but first, please check with our technical support whether you really need your own PHP in this situation.