GoAdmio

allowurlinclude

Read or set PHP allow_url_include across all php.ini files

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


Overview

allow_url_include is a PHP setting that lets include and require load code from a remote URL. /go/allowurlinclude sets it in every php.ini on the server in one run. It:

[!WARNING] Keep allow_url_include set to Off. Turning it on lets a flaw in a site load and run code from any server on the internet. PHP deprecated the setting in version 7.4, and it only works while allow_url_fopen is On (see allowurlfopen).


Quick start

# Turn allow_url_include off in every php.ini
/go/allowurlinclude Off

Syntax

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

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


Arguments

Argument Effect
(none) Sets allow_url_include = Off 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 Include 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_include line in the first file.

return exits with status 1.


Examples

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

Troubleshooting

Symptom Likely cause Fix
The success message appears but no file changed The server's OS is not AlmaLinux, Rocky, CentOS, Red Hat, Fedora, Debian, or Ubuntu. The command finds no files. Edit allow_url_include 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_include line, or the line is commented out. Set a value with /go/allowurlinclude 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

On any other OS, no files are found and nothing is changed.

How a file is changed

Situation Result
A line starting with allow_url_include = exists (leading spaces allowed) Every such line is replaced with allow_url_include = <value>.
No such line exists, or the line is commented out with ; allow_url_include = <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/allowurlinclude.log.

What a run does

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

See also

Command Description
allowurlfopen Toggle PHP allow_url_fopen 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