GoAdmio

allowurlfopen

Read or set PHP allow_url_fopen across all php.ini files

On this page: Overview · Quick start · Syntax · Arguments · Output · Examples · Troubleshooting · Details · See also


Overview

allow_url_fopen is a PHP setting that lets PHP functions such as file_get_contents() open remote URLs as if they were files. /go/allowurlfopen sets it in every php.ini on the server in one run. It:

[!WARNING] With no argument, the command sets allow_url_fopen to On. Off is safer, because it stops scripts from fetching remote files. Some applications, such as plugin and update checks, need On.


Quick start

# Turn allow_url_fopen off in every php.ini
/go/allowurlfopen Off

Syntax

/go/allowurlfopen [On|Off]
/go/allowurlfopen return

The command has no -- options. Run it as root.


Arguments

Argument Effect
(none) Sets allow_url_fopen = On in every php.ini.
On or Off Sets that value in every php.ini.
return Prints the current value and changes nothing. Not case sensitive.
Any other text Written to the setting as typed. The value is not checked.

If you pass several words, they are joined with spaces and all written as the value. Pass a single value, normally On or Off.


Output

Message Meaning
Allow URL Fopen updated successfully. The run finished. It is printed even when no php.ini was found or changed.
On or Off The current value, printed by return.
(an empty line) return found no active allow_url_fopen line in the first file.
Unknown operating system. The OS is not AlmaLinux, Rocky, CentOS, Red Hat, Fedora, Debian, or Ubuntu. Nothing is changed.

return exits with status 1.


Examples

# Turn the setting off everywhere
/go/allowurlfopen Off
# Turn the setting on everywhere
/go/allowurlfopen On
# Read the current value
/go/allowurlfopen return
# See the setting in every php.ini
grep -rH "^allow_url_fopen" /etc/php.ini /etc/php /etc/opt/remi 2>/dev/null
# Review the log of past runs
tail -n 20 /var/log/go/allowurlfopen.log

Troubleshooting

Symptom Likely cause Fix
Unknown operating system. The server's OS is not supported. Edit allow_url_fopen in php.ini by hand.
The site still behaves as before PHP-FPM has not reloaded yet. The reload is scheduled for one minute later. Wait a minute, or run reload. With Apache's mod_php, reload the web server too.
return prints an empty line The first php.ini has no active allow_url_fopen line, or the line is commented out. Set a value with /go/allowurlfopen On or Off.
return shows a value that your site does not use It reads only the first php.ini found, normally /etc/php.ini. Check the file of the PHP version your site uses with the grep command above.
The setting contains a wrong value, such as Of Values are not validated. Run the command again with On or Off.
The scheduled reload never happens The at service is not installed or not running. Run reload yourself.
Permission denied when adding a line The command was not run as root. Run it as root.

Details

Files that are changed

Only files that exist are changed. /etc/php.ini is always checked first.

OS Files
AlmaLinux, Rocky, CentOS, Red Hat, Fedora /etc/php.ini and /etc/opt/remi/<version>/php.ini for each version
Debian, Ubuntu /etc/php.ini and, for each version in /etc/php, the php.ini in fpm, cli, and apache2

How a file is changed

Situation Result
A line starting with allow_url_fopen = exists (leading spaces allowed) Every such line is replaced with allow_url_fopen = <value>.
No such line exists, or the line is commented out with ; allow_url_fopen = <value> is added at the end of the file.

The PHP-FPM reload

After the files are changed, the command schedules /go/fpm reload to run one minute later with at. If a reload is already waiting, it does not schedule another. The command-line php reads its file at each start, so it sees the change at once. See fpm.

Logging

Every run appends its arguments with a timestamp to /var/log/go/allowurlfopen.log.

What a run does

flowchart TD
    A["allowurlfopen [value]"] --> B{"Supported OS?"}
    B -- "No" --> X["Unknown operating system"]
    B -- "Yes" --> C["Collect php.ini files"]
    C --> D{"Argument is return?"}
    D -- "Yes" --> E["Print value from the first file, exit 1"]
    D -- "No" --> F["For each existing file: set the value"]
    F --> G["Print: updated successfully"]
    G --> H["Schedule fpm reload in 1 minute"]

See also

Command Description
allowurlinclude Toggle PHP allow_url_include across all php.ini files
disablefunctions Modify disable_functions for all PHP versions
displayerrors Toggle PHP display_errors across all php.ini files
fileuploads Toggle PHP file_uploads across all php.ini files
fpm Restart all installed PHP-FPM versions on your server
reload Reload PHP-FPM and the active web server
listphp List the available PHP versions on a GoAdmio server