How to enable allow_url_fopen for a single domain on a cPanel server?

The way to enable allow_url_fopen on a phpsuexec and a non-phpsuexec server is different. To enable allow_url_fopen server wide is a security risk, however, you can turn it ON for a single domain incase it is required.

Here how it needs to be done.

  • On a non phpsuexec server:

Goto the /usr/local/apache/conf/ directory,

# cd /usr/local/apache/conf/userdata

create a ‘userdata’ directory if not there and then create a directory with the accounts username inside it. Finally, you have to create a file allowurl.conf in the newly created directory.

The complete path should look like:

# pico /usr/local/apache/conf/userdata/<username>/allowurl.conf

and add the following to the file

<IfModule mod_php5.c>  
php_admin_value allow_url_fopen On 
php_admin_value allow_url_include On 
</IfModule> 

Now, edit the Apache configuration file and scroll down to the VirtualHost entry of the domain. Include the path of the above created file in it, as shown below:

Include "/usr/local/apache/conf/userdata/<username>/allowurl.conf"

Save the file and rebuild the apache configuration

# /usr/local/cpanel/bin/apache_conf_distiller --update 
# /usr/local/cpanel/bin/build_apache_conf 
# /scripts/restartsrv httpd

This will enable allow_url_fopen for that domain.

  • On a PhpSuExec Or SuPHP server:

To enable allow_url_fopen on a SuPHP/PHPSuExec enabled server, copy the server side php.ini OR create a new one under the public_html directory of the domain (OR in the directory where you want to enable allow_url_fopen) i.e.

# cp /usr/local/lib/php.ini /home/<username>/public_html/

and edit the new php.ini to enable allow_url_fopen directive:

allow_url_fopen = On

Save the file and this is it.

BTW, replace “<username>” with the actual username of the domain wherever stated above.

This entry was posted on Saturday, March 26th, 2011 and is filed under cPanel Management. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.