i'm almost done with the pset7 and this happend , something has gone wrong and cant figure it out . first i couldn't get the apache50 to start then i found this on web "echo > ~/lib/apache2/log/error.log" after that the apache50 worked but got an 403 error when loading the page then chmod 775 the pset7 directory now again stuck with this ."Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

  • 1
    Did you start mysql? Commented Jul 30, 2016 at 20:31
  • I stopped and start everything few times but didn't work anytime
    – Thisal
    Commented Aug 1, 2016 at 11:37

1 Answer 1


CS50 course materials will tell you that the permissions need to be set as follows:

chmod 711 for directories

chmod 644 for images, HTML, CSS, JavaScript

chmod 600 for PHP files.

In general, this is the correct advice.

However, if you have run update50 recently, you should know that there is a bug requiring chmod 640 instead for PHP files.

I've posted this elsewhere, but the quickest way to get what you want is to change directory to your project's workspace (in the example below, ~/workspace/pset7 ) and execute the following commands:

cd ~/workspace/pset7/
find . -type d | xargs chmod 711
find . -name *.php | xargs chmod 640

Hopefully, that will do it!

EDIT: In your case, you might also need to make certain that all the directories in the full path to your pset7 folder are set to chmod 711. The full path to your directory should be /home/ubuntu/workspace/pset7, so you should reset the permissions of the following directories:

chmod 711 /home/ubuntu/workspace/pset7
chmod 711 /home/ubuntu/workspace
chmod 711 /home/ubuntu

And, if necessary:

sudo chmod 711 /home
sudo chmod 711 /

(These last two should not be necessary, but I'm including them just in case!)


cd ~/workspace/pset7
chmod 640 config.json

config.json does not need to have the execute bit set for user, group, or world. In particular, it should never be world-readable, world-writable, or world-executable. This file contains your database authentication credentials in plaintext. You don't want that info in the wrong hands! So, in the real world, you would set this to chmod 600 just like your PHP files. However, in the current situation, chmod 640 is temporarily required due to a bug.

EDIT THREE (2016-08-05): Looks like the ide50 maintainers have released version 60! Go ahead and run update50 and hopefully it will fix all of the permission problems!

If this helps you to resolve your issue, please click the green check mark to accept my answer. Otherwise, the forum will forever list this question as unanswered!


It looks like the permissions have changed permanently (at least, the group read access will still be required for PHP files and config.json) and the problem specifications will need to be updated to reflect the new permissions. See this post on the CS50 Reddit for more info.

Setting aside the issue of whether the new permissions are "better" or "worse" than the old ones, I actually think this situation could be a blessing in disguise, since it's a great opportunity to teach people about debugging site permission issues with the Apache2 error log -- something you will spend many hours doing if you pursue a career as a professional web developer! ;)


This question seems to have become a magnet for traffic on this topic, so I'm updating it to announce that I've collected my advice on this topic from several sources into a catch-all document called 403 Forbidden / permissions / chmod -- the definitive guide on the CS50 Reddit.

Next time you see a 403 Forbidden error when you try to load a page, watch the Apache error log in the Terminal by executing the following command:

tail -f ~/lib/apache2/log/error.log

before reloading the page in the browser. You may find a more specific error message there. Meanwhile, don't lose heart! This process of reading Apache logs and PHP error messages to help resolve permission errors or other issues is actually something you'll do all the time as a professional web developer, so think of it as valuable practice rather than a waste of time!

  • See also my question. Also, if my answer helps you to resolve your issues, let me know by accepting my answer! :) Commented Jul 31, 2016 at 2:35
  • now these two errors appears when trying to access my web page 1."Warning: file_get_contents(/home/ubuntu/workspace/pset7/includes/../config.json): failed to open stream: Permission denied in /home/ubuntu/workspace/pset7/vendor/library50-php-5/CS50/CS50.php on line 95" 2.Fatal error: Could not read /home/ubuntu/workspace/pset7/includes/../config.json in /home/ubuntu/workspace/pset7/vendor/library50-php-5/CS50/CS50.php on line 98
    – Thisal
    Commented Aug 1, 2016 at 11:25
  • and YES I UPDATED MY WORKSPACE after that only this happened
    – Thisal
    Commented Aug 1, 2016 at 11:36
  • 1
    now i'm getting these two errors -1). Warning: require(/home/ubuntu/workspace/pset7/vendor/library50-php-5/CS50/CS50.php): failed to open stream: Permission denied in /home/ubuntu/workspace/pset7/includes/config.php on line 20 2).Fatal error: require(): Failed opening required '../vendor/library50-php-5/CS50/CS50.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/ubuntu/workspace/pset7/includes/config.php on line 20
    – Thisal
    Commented Aug 3, 2016 at 7:24
  • 1
    after running the line "tail -f ~/lib/apache2/log/error.log" it worked , I also chmod 777 the - "/home/ubuntu/workspace/pset7/vendor/library50-php-5/CS50/CS50.php" but now i cant do anything on phpmyadmin , after i goto the page and chick something i'm getting an Error: token mismatch
    – Thisal
    Commented Aug 5, 2016 at 9:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .