PHP Options

Per-Domain php.ini settings - start point

With the many different types of php modes, this means the method of adding custom per-domain changes can vary greatly. Check your custombuild options.conf to determine which php1_mode you're using, and find the related guide below.


php-fpm is handy for multiple instances of php, allowing the User to change php version from within their User Level area. php-fpm does not support .htaccess changes as php-fpm is it's own stand-alone php server, but you can use

  1. php-fpmXX.conf custom settings
  2. php [PATH] or [HOST] sections
  3. User controlled .user.ini


The fastcgi mode is effective, but some find it somewhat rigid in it's flexibility (blend of suphp and php-fpm). To edit per-domain settings, you have 2 options:

  1. Manually create the .ini file at /usr/local/directadmin/data/users/username/php/ and the call to fastcgi will read that in if it exists.

Note that it's a full replacement and not an 'addon' ini, so ensure you have all settings you need in that file, as the default php.ini isn't used here. Take a look inside the User's httpd.conf to see which .sh script is called, and the variables passed. Then check inside that .sh script for more info on how it works.

  1. php [PATH] or [HOST] sections

Note that some settings like disable_functions can only be set once in the main php.ini file, and cannot be overridden by other areas, but this varies per php-mode. php-modes like php-fpm/fastcgi are much more stand-alone php instances, so you can get away with these types of overrides, away from the main php.ini.

Where is my php.ini?

Depending of a setup the location of php.ini may vary. The easiest trick to find your php.ini would be to ask php itself what it's using, eg:

/usr/local/bin/php --ini | grep 'Loaded Configuration File'

which does assume that the php output will be in English.

Usually your php.ini will be located at (XX - PHP version, for example 73):


CustomBuild 2.0 installs will also uses the php.conf.d directory to load miscellaneous .ini files into php. The files that CustomBuild will create are:


You can add your own files there if you need to add settings or load modules into php, for example /usr/local/phpXX/lib/php.conf.d/11-custom.ini and place custom options inside.

The ever best option is to place phpinfo() page inside a domain DocumentRoot directory, create the file phpmyinfo.php with content:


Next open it in browser: and watch for 'Loaded Configuration File' and 'Scan this dir for additional .ini files' .

How to increase the max upload filesize

Find where is your php.ini then edit it.

Search for

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

Change the 2M to whatever new value you want, then restart apache.

Note, this setting may also be related:

; Maximum size of POST data that PHP will accept.
post_max_size = 8M

Note, some RoundCube versions have limits set in the file /var/www/html/roundcube/.htaccess so be sure to increase them there as well, if they are set.

For PHP-FPM service use this article.

Fatal error: Allowed memory size exhausted

If you see the error like:

Fatal error: Allowed memory size of 123456 bytes exhausted (tried to allocate 234567 bytes) in /path/file.php

Php is setup is to limit memory usage per process. If you require more, this limit can be increased.

Find where is your php.ini then edit it, search for

memory_limit = 8M

to a higher value, like 128M. Save, exit, then restart apache.

For PHP-FPM service use this article.

How to use per-domain or per-path settings for php

CustomBuild 2.0 uses a folder for additional php.ini files, loaded if they exist in the folder. The install path can vary depending on the php mode; in this example, we'll use /usr/local/lib/php.conf.d but for other php modes, if the php version is 5.6, the path might be:


You can determine where you php.ini and php.conf.d folder is by using the where is my php.ini guide.

Once you know the path, let's use in our example, you can then create your custom ini file. The load of the ini files is done alphabetically, so we number the files to control in which order they're loaded in. Usually the order doesn't matter too much, unless you're altering settings for a module that should be loaded first.

1. Per-domain settings

If you would like to create per-domain settings for , you could create:


And add code like:


2. Per-path settings

Similarly, you can alter settings on a per-path basis, say for User which is handy if you want the settings to apply to a domains under that given path (usually, on a per-User basis), edit the file:


And set, for example:


In the above examples, it is implying the use of one file for each item you want to separate. This is not required. You can use one additional file to make load times faster, but also to hide the list of domains from the phpinfo() output, as all "additional" loaded php.ini files are displayed, so if you were to use:


you could add many [HOST=xx] entries into the same file, one after the other.

Based on:

How to allow <? and not require <?php

If you have scripts with the php tags:


but php isn't parsing the code between those tags, php may be set to require:


You can force php to allow the short tags by setting the following in your php.ini:


Related: Where is my php.ini

How to disable magic-quotes

If you need to disable magic quotes, the easiest way is to edit your php.ini and set:

magic_quotes_gpc = Off

and then restart apache.

Another way is to edit your php configure file and remove the line:

--enable-magic-quotes \

and recompile php.

Testing which uid php is running as to debug read/write issues

Often times, a php script needs write access to disk. Most installs will use php-fpm, fastcgi or lsphp which should all run php as the given User, rather than as "apache".

To determine what uid a php process is running as, you can use this script to get a definitive answer:


Save this to an info.php file in a path you're trying to debug, then view it through Apache.

Note that this requires that both "system" and "phpinfo" not be set in your disable_functions list in your php.ini.

Last Updated: