customize PHP disable_functions
Customizing the disable_functions
directive in PHP within DirectAdmin involves editing the appropriate PHP configuration file (php.ini) and specifying which functions you want to disable for security or performance reasons. Here’s how you can do it:
Step-by-Step Guide customize PHP disable_functions
- Log in to DirectAdmin:
- Open your DirectAdmin control panel and log in with your credentials.
- Access PHP Settings:
- Once logged in, navigate to the “Admin Tools” section and click on “File Editor” or “Custom HTTPD Configurations” if available.
3.Edit the php.ini File:
-
- If you have multiple PHP versions, ensure you select the correct version you want to configure.
- Locate the php.ini file. The path to this file varies depending on your server configuration, but common locations include:
/usr/local/lib/php.ini
/usr/local/phpXX/lib/php.ini
(where XX corresponds to the PHP version, e.g., 81 for PHP 8.1)
4.Modify disable_functions Directive:
-
- Open the php.ini file for editing.
- Locate the
disable_functions
directive. It might look something like this:
disable_functions = exec,passthru,shell_exec,system
Add or remove functions as needed. For example, to disable additional functions:
disable_functions = exec,passthru,shell_exec,system,proc_open,popen
If the directive is not present, you can add it anywhere in the file:
disable_functions = exec,passthru,shell_exec,system,proc_open,popen![]()
5.Save and Restart PHP:
- Save your changes to the php.ini file.
- Restart the PHP service to apply the changes. This can typically be done via DirectAdmin’s interface or through the command line. For example, on a systemd-based system, you might use:
systemctl restart php-fpm
Example for Multiple PHP Versions
If you have multiple PHP versions running on your server, you need to repeat the above steps for each version’s php.ini file.
Using Custom HTTPD Configurations
Alternatively, if DirectAdmin provides an option for custom HTTPD configurations, you can add the disable_functions
directive directly in a custom configuration file for a specific domain:
- Navigate to Custom HTTPD Configurations:
- Go to “User Level” or “Reseller Level” depending on your access.
- Find the domain you want to configure and select “Custom HTTPD Configurations.”
- Add PHP Configuration:
- In the custom configuration, you can add the PHP directive. For example:
<IfModule mod_php7.c> php_admin_value disable_functions "exec,passthru,shell_exec,system,proc_open,popen" </IfModule>
Save the changes and restart the web server.
Verifying the Changes
To verify that your changes have taken effect:
- Create a PHP Info File:
- Create a file named
info.php
in your web root directory with the following content:
- Create a file named
<?php phpinfo(); ?>