0

I'm trying out the tutorials for Facebook developers. However, I can't include the Facebook PHP SDK successfully in my code. As stated, require_once("facebook_sdk/facebook.php"); throws the following error:

Warning: require_once(facebook_sdk/facebook.php) [function.require-once]: failed to
open stream: Permission denied in /opt/lampp/htdocs/awesome/plas.php on line 2

Fatal error: require_once() [function.require]: Failed opening required 'facebook_sdk/facebook.php'
(include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/awesome/plas.php on line 2

I am developing under Lucid Lynx. I tried doing chmod 777 facebook.php but the problem persists. I found this SO question but the resolution arrived at (renaming the file, as it may be conflicting with one of PHP's own) does not work for me. (Come to think of it, how will a file named facebook.php conflict with internal PHP files?!) Even if I switch to plain require, the same warnings are thrown.

Curiously, if I copy the files (facebook.php and base_facebook.php) outside of facebook_sdk and change the require_once line accordingly, the require succeeds. Any thoughts?

Community
  • 1
  • 1
skytreader
  • 11,467
  • 7
  • 43
  • 61
  • 1
    chmod the directory as well the files are placed in. Looks like you don't have enough rights to touch files in that directory. – hakre Dec 23 '11 at 19:31
  • What's in `/opt/lampp/lib/php`? Is there a `/opt/lampp/lib/php/facebook_sdk/facebook.php` file? – ceejayoz Dec 23 '11 at 19:31
  • You nailed it hakre. If you'd turn that to an answer, I'd gladly accept. Thanks! (--,) – skytreader Dec 23 '11 at 19:34
  • possible duplicate of [require\_once failed to open stream permission denied](http://stackoverflow.com/questions/1197493/require-once-failed-to-open-stream-permission-denied) – leo Dec 16 '14 at 15:48

1 Answers1

1

Your web server needs read access right to facebook_sdk/facebook.php. You can do it by chowning the directory to the web server user. chmod 777 is not a good practice.

Also make sure for each of include path, facebook_sdk/facebook.php exists.

Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187
  • 1
    Thanks for the additional "best practice" tip! Actually, I only do `chmod 777` when I'm too lazy to specify permission bits and I just want to have access. It only happens while on localhost and never on the actual server. – skytreader Dec 24 '11 at 19:40