Theme editor

How to Enable exec in CloudLinux and DirectAdmin

Aior

Administrator
Staff member
Joined
Apr 2, 2023
Messages
83
Reaction score
2
Points
8
Age
39
Location
Turkey
Website
aior.com

How to Enable exec in CloudLinux and DirectAdmin

Enabling the PHP exec function on a server running CloudLinux and DirectAdmin involves modifying the PHP configuration and then restarting your web server. This guide walks you through the process step-by-step.
Overview

In a typical CloudLinux environment managed with DirectAdmin, PHP configurations are often set to disable potentially dangerous functions like exec for security reasons. However, if your application requires the use of exec, you can enable it by editing the relevant PHP configuration file and restarting the web server. Remember that enabling exec can expose your server to security risks, so only enable it if you trust the code and environment.

Step 1: Modify the PHP Configuration File

1. Open the PHP Configuration File:

The primary PHP configuration file in your environment is usually located at:

/opt/alt/php73/etc/php.ini
Open this file using your favorite text editor (here, we use nano):

Code:
nano /opt/alt/php73/etc/php.ini

2. Edit the disable_functions Directive:

Within the php.ini file, locate the line that contains the disable_functions directive. It might look like this:

Code:
disable_functions = exec, other_function1, other_function2
Remove exec from the list so that it appears as either:
Code:
disable_functions = other_function1, other_function2
or, if you want to enable all functions, clear the directive: (Not recommended)

disable_functions =

3. Save and Exit:

After making your changes, save the file and exit the editor. In nano, you can do this by pressing CTRL + O to write the changes and CTRL + X to exit.

Step 2: Restart the Web Server


To apply the configuration changes, you need to restart your web server. If you are using Apache (httpd), run the following command:
Code:
systemctl restart httpd
For other web servers, such as LiteSpeed, ensure you restart the corresponding service.

Step 3: Additional Considerations


Using CloudLinux PHP Selector

If your setup uses CloudLinux’s PHP Selector through DirectAdmin, you might also need to update the PHP Selector settings:

• Log into the DirectAdmin control panel.

• Navigate to the CloudLinux PHP Selector section.

• Edit the PHP options to remove exec from the disable_functions list.

• Save your changes.

Checking User-Specific PHP-FPM Configuration

If you are running PHP-FPM with user-specific configuration files (often located in /usr/local/directadmin/data/users/username/php/ or /etc/php-fpm.d/), ensure that the disable_functions directive in those files does not include exec.

Security Considerations

Security Risks: Enabling exec can pose significant security risks if exploited. Ensure that only trusted code is executed, and consider applying additional restrictions such as open_basedir or other security measures.

Monitoring: Regularly review your server’s security logs and configuration to catch any potential misuse of the execfunction.

Conclusion

By following the steps above, you can enable the exec function on a CloudLinux server managed by DirectAdmin. Edit your /opt/alt/php73/etc/php.ini file to remove exec from the disable_functions directive, restart your web server, and check for any additional configurations that might override these settings. Always remain vigilant regarding security and consider the implications of enabling potentially hazardous PHP functions.
 

Featured content

Back
Top