Cpanel and Custom PHP.ini


Cpanel and Custom PHP.iniI was working on helping someone migrate a WordPress blog to Drupal. It began with a review of of a couple of modules to do the trick including wordpress_import and wordpress_migrate. To sum it up, we went with wordpress_migrate for its handling of attachments and leveraging of existing infrastructure including the migrate module. The problem we ran into was when dealing with attachments. The content created by the import still referenced images from the WP blog rather than grabbing them and saving them as files in the Drupal site and modifying the post image source tags.

After review a few things, it became apparent that the host being used, A2Hosting.com, correctly has PHP’s fopen function disabled. Kudos to A2Hosting for that. Now, they offer a form that the customer can request this to be enabled with the caveat of security blah blah blah. We didn’t want to enable this permanently, only for the duration of the import. Again, some quick searches regarding Cpanel and custom php.ini’s led to the following solution.

Copy PHP.Ini and Force reading in .htaccess

Make a copy of the existing php.ini that the server uses and place it in your account home directory.

Next, edit the PHP.ini to set allow_url_fopen = On

Finally, edit the .htaccess file in the root of the Drupal installation directory and add the following:

Save. This now allowed our Drupal installation to run php with the directives in our custom php.ini with fopen allowed. The migration took all of maybe 30 seconds and we were done.

When we finished, we just reversed the process so we didn’t stay on our special php.ini and complicate life later down the road with the host.

Hope it helps.


About Tom

Tom genuinely loves tech. Not just gadgets but game changing stuff. Oh yeah, he hates to talk about himself in the 3rd person. So, I really enjoy involvement in sharing big tech in the #nptech (nonprofit technology) arena. The need to be entrepreneurial drives me to learn and dive into projects, but without the financial acumen to go it alone. Visit me in the afternoon and you'll see Google Chrome packed with my tab hoarding tendencies and you might even catch me practicing my fake british, over the top, accent. Christ follower, husband, father and technology enthusiast. Attempting to live life out as a light in this world and stumbling at times in this fallen world.

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

By submitting this form, you accept the Mollom privacy policy.