There are a few methods that you can use to customize php.ini when using DirectAdmin. In this article, I’m going to show you how to customize php.ini for each different domain that you have.
DirectAdmin has the ability to customize php.ini for each domain and this feature is only available starting DirectAdmin version 1.61.4+. If you are using an older version of Directadmin, it is recommended to upgrade to this version first to use this feature.
Related feature: https://www.directadmin.com/features.php?id=2780
There are 2 methods to customize php.ini per domain:
Method 1: Customize php.ini per-domain using DirectAdmin GUI
Step 1: Go to Directadmin control panel navigation -> Account Manager -> PHP Settings (see screenshot below):
Step 2: Choose a predefined setting in the dropdown link in the setting field (eg: memory_limit) and change the value to something else like 128M then click the Add button (refer to screenshot below):
Finally, after you have clicked the Add button, your custom php.ini changes on your DOMAIN.com will take effect within a few seconds.
Method 2: Customize php.ini per-domain using command-line (unofficial)
Even though this method is not documented in Directadmin, there is a benefit of using the command-line method here but this method is only available if you have admin or root access to your server. The limitation of using GUI is, you are limited to only a few predefined options for editing the php.ini. For example, if you want to change the PHP timezone for your DOMAIN.COM, you won’t be able to see this option defined in GUI. So, without wasting time let’s see how you can do that using command lines:
- Assume you want to set a PHP timezone for your DOMAIN.COM to Asia/Kuala_Lumpur
- First login into your directadmin server (eg: via SSH)
- Edit the following file (replace USERNAME and DOMAIN.COM with yours)
4. After that, add the following entry as a new line inside the file DOMAIN.COM.php.ini
5. Save the file by pressing CTRL + x, and y
6. Next, you should run the following command to update server configs:
7. To verify that you have successfully added the PHP timezone entry above, you can run the following command for each PHP that you have:
grep "php_value[date.timezone]" "/usr/local/directadmin/data/users/USERNAME/php/php-fpm74.conf" grep "php_value[date.timezone]" "/usr/local/directadmin/data/users/USERNAME/php/php-fpm80.conf"
Finally, if you saw the following output below then it means, it is working perfectly:
php_value[date.timezone] = "Asia/Kuala_Lumpur"