0

In the first HTML lecture, Malan gives instructions on accessing an html page in the CS50 IDE as an external user. I ran update50. I started the apache50 server successfully. I tried to access my html content via the link the IDE provided and got "403 Forbidden". I then ran chmod 755 ~/workspace/Week-6, which got me a list of the directory's contents when I used the external URL. Clicking on the html file, however, still returns "403 Forbidden." I've tried some of the suggestions for pset6, but some of them are "missing an operator."

Any thoughts or suggestions on a remedy would be appreciated.

2 Answers 2

2
  1. That is the mode required to access a file with apache50 server. You will need to chmod 644 the html file, or any file, to get rid of the "403 Forbidden" error.
1

@DinoCoderSaurus is right.

See also 403 Forbidden / permissions / chmod -- the definitive guide on the CS50 Reddit, for details on the minimum required permissions for different types of file.

TL;DR:

  • It's 711 for directories (unless you want Apache2 to generate a dynamic index when there is no index.html or index.php provided, then it's 755).
  • It's 644 for most everything else -- HTML, CSS, image and font files.
  • For PHP files and JSON files, you can lock permissions down to 640 (and outside the CS50 IDE, you may even be able to lock them down to 600).
  • Finally, you may have files and directories in your problem set directory that you don't want to share online at all (as with ./bin/import in Problem Set 8) and for these files, you should restrict permissions to 700.
5
  • I'm trying to do this as well, but I still keep getting the 403 error. I did "chmod a+r hello.html" and I even tried entering the absolute path to the file with it. I also tried 711 and 644. What am I missing? Commented Dec 3, 2016 at 12:41
  • You should use 711 for all the directories in the path to Apache's root directory, and 644 for hello.html. And if you are still getting a 403 error, you should look at Apache's error log by typing tail -f ~/lib/apache2/log/error.log in the Terminal. You will probably see more detailed error messages there. And if you are still stuck, read the Definitive Guide. Commented Dec 3, 2016 at 14:16
  • 1
    what do I do if I got permissions for the web part but lost reading permissions for all of my stuff in the pset1 through pset4 directories (as well as the pset6 and section and walkthrough directories I have)? Commented Dec 3, 2016 at 23:44
  • If you lost read permissions to all of the directories in your workspace, use find ~ -type d | xargs chmod 711 to fix permissions just on directories, recursively throughout your entire workspace. But don't just copy that command; read my guide and learn about how it works. Commented Dec 5, 2016 at 1:32
  • 1
    Yeah, it was apparently a temporary thing and it was fixed sometime later. I can access my files now and am following David's walkthroughs without trouble. Thanks anyway. Commented Dec 6, 2016 at 22:19

You must log in to answer this question.

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