What is allow_url_fopen and How to Enable in cPanel

What is allow_url_fopen and How to Enable in cPanel
Table of Content

The allow_url_fopen is a setting managed through the PHP Options which allows PHP file functions to retrieve data from remote locations over FTP or HTTP. This option is a significant security risk, thus, do not turn it on without necessity.

How to enable or disable allow_url_fopen in cPanel

There are specific scenarios when you may be asked to change your PHP configuration. Specifically, you may be directed to edit a file on your server called php.ini and to enable or disable allow_url_fopen.

How to Enable or Disable allow_url_fopen in cPanel

The PHP Selector is omitted by default in cPanel and might be missing from your account if you are hosting with a different web host. All customers should see the Select PHP Version section in their hosting account’s cPanel.

While do not allow direct changes to PHP.ini on our servers. However, PHP configuration changes can be made from cPanel by following these steps:

1) Log into cPanel.

2) Look for the SOFTWARE section and click on Select PHP version

PHP Version
Software > Select PHP Version

3) Click on the Options link in the new window.

PHP Selector > Options

4) You can locate the allow_url_fopen and tick on the box next to it to enable it or un-tick the box to disable it.

allow_url_fopen

5) Once you make any changes, please do a left-hand side click anywhere outside the dropdown or text input box. If the change were successful, you would see a green box with a message confirming that the change has been applied.

That’s all! Now you know how to enable or disable allow_url_fopen in cPanel.

Using the allow_url_fopen directive

The allow_url_fopen directive is disabled by default. You should be aware of the security implications of enabling the allow_url_fopen directive. PHP scripts that can access remote files are potentially vulnerable to arbitrary code injection.

When the allow_url_fopen directive is enabled, you can write scripts that open remote files as if they are local files. For example, you can use the file_get_contents function to retrieve the contents of a web page.

To enable this functionality, use a text editor to modify the allow_url_fopen directive in the php.ini file as follows:

allow_url_fopen = on

To disable this functionality, modify the allow_url_fopen directive in the php.ini file as follows:

allow_url_fopen = off

To verify the current value of the allow_url_fopen directive and other directives, you can use the phpinfo() function.