disablefunctions
Show, set, or clear PHP's
disable_functionssetting in every php.ini on the server
- Command:
/go/disablefunctions - Category: PHP
- Required option: None
- Output: Nothing when setting; the current list with
return - Last updated: 2026-11-20
On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also
Overview
/go/disablefunctions manages PHP's disable_functions setting, the list of PHP functions that scripts are not allowed to call. Blocking risky functions such as exec or shell_exec is a common way to limit the damage if a website is compromised.
The command writes the same list into every php.ini it finds, for all installed PHP versions, and then schedules a PHP-FPM reload so the change takes effect.
[!WARNING] Running the command with no arguments clears the list, which allows every PHP function. To see the current list without changing it, use
return. Disabling functions can also break plugins and applications that need them.
Quick start
# Show the current list
/go/disablefunctions return
# Set the list
/go/disablefunctions "exec,passthru,shell_exec,system,proc_open,popen"
# Clear the list (allows every function)
/go/disablefunctions
Syntax
# Show the current list
/go/disablefunctions return
# Set the list
/go/disablefunctions <functions>
# Clear the list
/go/disablefunctions
Run the command as root.
Arguments
| Argument | Required | Notes |
|---|---|---|
return |
No | Prints the current list and changes nothing. Not case-sensitive. |
<functions> |
No | The functions to disable. Use one quoted, comma-separated argument, as in "exec,shell_exec". If you pass several separate arguments, they are joined with spaces. |
| (none) | No | Sets the list to empty, so no function is disabled. |
The new list replaces the old one. It is not added to it. Run return first and copy the current list if you want to keep its entries.
Output
When setting or clearing the list, the command prints nothing. If the at package has to be installed first, the package manager's output is shown.
With return, it prints the current list on one line, for example:
exec,passthru,shell_exec,system
A blank line means no value is set. The command then exits with status 1, even though nothing went wrong.
| Message | Meaning |
|---|---|
Unknown operating system. |
The OS is not AlmaLinux, Rocky, CentOS, Red Hat, Fedora, Debian, or Ubuntu. Nothing is changed. |
Examples
# Save the current list, then replace it
/go/disablefunctions return > /root/disable_functions.bak
/go/disablefunctions "exec,passthru,shell_exec,system,proc_open,popen"
# Check the value that PHP on the command line is using
php -r 'echo ini_get("disable_functions"), PHP_EOL;'
# Compare the value in every php.ini
sudo grep -H '^disable_functions' /etc/php.ini /etc/opt/remi/*/php.ini 2>/dev/null
# Remove all restrictions
/go/disablefunctions
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| All restrictions disappeared | The command was run with no arguments. | Set the list again. Use return to save the list before changing it. |
return prints an empty line |
The first php.ini found has no value. |
Check every file with the grep example above. |
return shows a different value than a website uses |
It prints only the first file it finds. | Compare all files. A site's own PHP-FPM pool setting can also override php.ini. |
| The change isn't active on my sites | The PHP-FPM reload runs about a minute later. Apache's mod_php is not reloaded by it. |
Wait a minute. On mod_php servers, reload the web server with reload. |
| The reload never happens | The at scheduler (atd) isn't running. |
Check it with systemctl status atd, or run /go/fpm reload yourself. |
Permission denied |
The command was not run as root. | Run it as root. |
| A plugin or script stopped working | It needs a function you disabled. | Remove that function from the list. |
Unknown operating system. |
The OS is not supported. | Edit php.ini by hand. |
Details
Files it changes
| Operating system | Files |
|---|---|
| AlmaLinux, Rocky, CentOS, Red Hat, Fedora | /etc/php.ini and /etc/opt/remi/<version>/php.ini for each version found. |
| Debian, Ubuntu | /etc/php/<version>/fpm/php.ini, cli/php.ini, and apache2/php.ini for each version found. |
Files that don't exist are skipped. The command also changes the command-line (CLI) configuration on Debian and Ubuntu, so check that your cron jobs don't depend on a function you disable.
What it does
flowchart TD
A["disablefunctions [return or list]"] --> B{"Supported OS?"}
B -- "No" --> X["Print Unknown operating system"]
B -- "Yes" --> C["Install the at package if it is missing"]
C --> D["Build the list of php.ini files"]
D --> E{"First argument is return?"}
E -- "Yes" --> F["Print the first value found, exit 1"]
E -- "No" --> G["For each php.ini: replace or add disable_functions"]
G --> H{"Reload already scheduled?"}
H -- "No" --> I["Schedule fpm reload in 1 minute"]
H -- "Yes" --> J["Done"]
I --> J
- Appends the call to
/var/log/go/disablefunctions.log. - Installs the
atscheduler if it is missing. - Builds the list of
php.inifiles for the OS. - With
return, prints the value from the first file that exists, and stops. - Otherwise, in each existing file, replaces the
disable_functions =line with the new value. If the file has no such line, it adds one at the end. A commented-out line (starting with;) is left alone, and a new line is added. - Schedules
/go/fpm reloadto run one minute later, unless a reload is already waiting in theatqueue.
Side effects
- The new list replaces the old one in every file, with no backup.
- The reload is delayed by about a minute, and a second run within that minute doesn't schedule another one.
- Lines are added to files that lack the setting without
sudo, so the command must run as root.
See also
| Command | Description |
|---|---|
allowurlfopen |
Toggle PHP allow_url_fopen across all php.ini files |
allowurlinclude |
Toggle PHP allow_url_include across all php.ini files |
memorylimit |
Change the PHP memory limit for all PHP versions |
checkphpini |
Scan every php.ini for startup errors and remove the offending line |
fpm |
Restart all installed PHP-FPM versions on your server |
reload |
Reload PHP-FPM and the active web server |
scan |
Scan newly modified PHP files for shells and the root password |