Posted by & filed under PHP, Web Server.

After our recent transition to MediaTemple, we realized that our homepage wasn’t being updated with our latest Twitter posts. As it turns out, the server has the ability to access remote files disabled by default, which is a good thing to prevent Remote File Injection attacks, but a bad thing if you want your Twitter account to update your homepage ;).

So, to fix this, you’ll need to re-enable it in your php.ini file. If you’re using the (gs) plan, you’ll want to FTP into your domain, go to the root folder, go into the etc folder, and add a file named php.ini with the following contents:

allow_url_fopen = On

This will let file_get_contents() and fopen() have the ability to accept URL’s as an argument.

Thomas Hunter II

Thomas is passionate about technology and building products. A web design business created while attending college slowly evolved into a brick and mortar on Main St. of his small Midwestern hometown. His desire for fame and fortune led to the co-founding of a Y Combinator startup and a life in California.

Tags:

Hey there! I'm currently writing a book on Microservices which I expect to release in early 2017. If you're interested in getting updates please signup here. More info about the Book
  • Thank you for sharing this with the community!

    Scott DeSmet
    (mt) Media Temple

  • thanks! worked perfectly on a client site hosted with MT.

  • Michael Pelz-Sheman

    This isn’t working for me for a PHP script run as a cron job. I also tried setting the option in my script using ini_set, to no avail. Still getting “Warning: fopen(): URL file-access is disabled in the server configuration” when I run the script. Any suggestions?

    • MT might have a separate php.ini for CLI vs httpd executed PHP (I’ve seen some distro’s do this).

      So, you might want to try having your CRON execute your script by doing a “wget http://URL“, instead of a “php /path/to/file”.

      Otherwise, you could always edit the script and switch to using cURL instead of fopen.

  • how to fix
    failed to open stream: HTTP request failed! HTTP/1.1 505 HTTP Version Not Supported