For security reasons most hosts will have fopen disabled. This is for security reasons but there are also times when it is legitimately needed. Below I will show you how to enable fopen for a single cPanel user instead of server wide.
This may be the error you get:
Warning: fopen(): URL file-access is disabled in the server configuration
Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration
Here’s how to fix it:
You will need shell access to the server and i’m assuming that you are the server administrator and not just a user on the server. If you are just a user on the server you can just create your own php.ini file in your public_html directory and change the setting explained below.
I recommend using the PHP.ini manager for cPanel/WHM instead of custom files, you can find more information here:
There’s also great information on the cPanel forum about adding specific entries for specific directories:
First let’s find out where our PHP.INI file is located at, do so with this command:
php5 -i | grep php.ini
You should get an output similar to this:
php5 -i | grep php.ini Configuration File (php.ini) Path => /usr/local/lib Loaded Configuration File => /usr/local/lib/php.ini
That tells us that our current loaded PHP.INI file is located at /usr/local/lib/php.ini. We will need this file because we will be creating a copy of it in the users public_html directory.
Change directory into the users public_html folder:
Let’s verify that a PHP.INI does not already exist:
find -type f -name "php.ini"
If you do not find a PHP.INI file with the above command, copy the PHP.INI file we just found using this command:
UPDATE: I do not recommend copying the entire file, this could cause issues with references in the php.ini file pointing at old modules, etc.
Recommendation is to just create a new php.ini file and put allow_url_fopen=On in it. Add the suPHP_ConfigPath below and it should work
cp /usr/local/lib/php.ini ./
Now we need to assign the user as the owner and group, do this with chown:
chown user.user php.ini
Now we need to add the configpath to the .htaccess file, use this command to add it:
echo 'suPHP_ConfigPath /home/user/public_html' >> .htaccess
You have now successfully setup a custom PHP.INI file for that specific user.
In order to enable fopen, use nano or your favorite editor and open the php.ini file.
and change the setting to ON.