2

I can't access ide50-username.cs50.io. Please, take a look at my chmod commands. I have done them 3 times, and at the third run I have decided to do each one separately to make sure each one is correct. I get

Forbidden

You don't have permission to access / on this server.

Apache/2.4.7 (Ubuntu) Server at ide50-username.cs50.io Port 443

~/workspace/pset8/ $ chmod 700 ~/workspace/pset8/bin
~/workspace/pset8/ $ chmod 700 ~/workspace/pset8/bin/import
~/workspace/pset8/ $ chmod 700 ~/workspace/pset8/includes
~/workspace/pset8/ $ chmod 700 ~/workspace/pset8/vendor
~/workspace/pset8/ $ chmod 711 ~/workspace/pset8/public
~/workspace/pset8/ $ chmod 711 ~/workspace/pset8/public/css
~/workspace/pset8/ $ chmod 711 ~/workspace/pset8/public/fonts
~/workspace/pset8/ $ chmod 711 ~/workspace/pset8/public/img
~/workspace/pset8/ $ chmod 711 ~/workspace/pset8/public/js
~/workspace/pset8/ $ chmod 600 ~/workspace/pset8/includes/*.php
~/workspace/pset8/ $ chmod 600 ~/workspace/pset8/public/*.php                                                                                                      
~/workspace/pset8/ $ chmod 644 ~/workspace/pset8/public/css/*
~/workspace/pset8/ $ chmod 644 ~/workspace/pset8/public/fonts/*
~/workspace/pset8/ $ chmod 644 ~/workspace/pset8/public/img/*
~/workspace/pset8/ $ chmod 644 ~/workspace/pset8/public/index.html
~/workspace/pset8/ $ chmod 644 ~/workspace/pset8/public/js/*
~/workspace/pset8/ $ apache50 start ~/workspace/pset8/public

But I can access phpmyadmin and have created the required table pset8.places.

I didn't have any such issues during pset7; pset7 files worked, except for the one that contained email sending code; though I am still figuring out how to run pset7 on my machine.

I will be grateful for support on this issue. Thank you very much!

UPDATE1: @Matt Obert I am sorry for posting the results in comments (will delete those now) - I should have figured out that updates are the best way to post code blocks ) I understand how vexing my mistake is. Sorry.

The answer to Problem One "Permission on config.json": my mistake, I have not posted the corrected permission of 640, which I have set to config.json after you have recommended it a few days ago; thus config.json has had rw-r-- persmissions when I performed the rest of tests.

-rw-r----- 1 ubuntu ubuntu  137 Nov  5  2015 config.json

UPDATE2: I have checked all permissions once again, compared them with your ones, and have made few corrections.

~/workspace/ $ ls -l / |grep home
drwxr-xr-x   13 root root  4096 Dec  8  2015 home/
~/workspace/ $ ls -l /home |grep ubuntu
drwxr-xr-x 21 ubuntu ubuntu  4096 Aug 17 09:12 ubuntu/
~/workspace/ $ ls -l /home/ubuntu |grep workspace
drwxrwxr-x 15 ubuntu ubuntu 4096 Aug 15 08:26 workspace/
~/workspace/ $ chmod 755 /home/ubuntu/workspace
~/workspace/ $ ls -l /home/ubuntu |grep workspace
drwxr-xr-x 15 ubuntu ubuntu 4096 Aug 15 08:26 workspace/
~/workspace/ $ ls -l /home/ubuntu/workspace |grep pset8
drwx------ 6 ubuntu ubuntu    4096 Nov  5  2015 pset8/
-rw--w---- 1 ubuntu ubuntu     688 Aug 14 11:53 pset8.sql
~/workspace/ $ chmod 755 /home/ubuntu/workspace/pset8
~/workspace/ $ ls -l /home/ubuntu/workspace |grep pset8
drwxr-xr-x 6 ubuntu ubuntu    4096 Nov  5  2015 pset8/
-rw--w---- 1 ubuntu ubuntu     688 Aug 14 11:53 pset8.sql
~/workspace/ $  
~/workspace/ $ ls -l /home/ubuntu/workspace/pset8
total 20
drwx------ 2 ubuntu ubuntu 4096 Nov  7  2014 bin/
-rw-r----- 1 ubuntu ubuntu  150 Aug 17 08:16 config.json
drwx--x--x 2 ubuntu ubuntu 4096 Nov  5  2015 includes/
drwx--x--x 6 ubuntu ubuntu 4096 Nov  5  2015 public/
drwx--x--x 3 ubuntu ubuntu 4096 Oct 26  2015 vendor/
~/workspace/ $ 
~/workspace/ $ ls -l /home/ubuntu/workspace/pset8/public
total 32
-rw-r----- 1 ubuntu ubuntu  422 Nov  5  2015 articles.php
drwx--x--x 2 ubuntu ubuntu 4096 Nov  5  2015 css/
drwx--x--x 2 ubuntu ubuntu 4096 Nov  5  2015 fonts/
drwx--x--x 2 ubuntu ubuntu 4096 Nov  7  2014 img/
-rw-r--r-- 1 ubuntu ubuntu 1823 Nov  5  2015 index.html
drwx--x--x 2 ubuntu ubuntu 4096 Nov  6  2015 js/
-rw-r----- 1 ubuntu ubuntu  374 Nov  5  2015 search.php
-rw-r----- 1 ubuntu ubuntu 1526 Nov  5  2015 update.php
~/workspace/ $ apache50 start ~/workspace/pset8/public

I see the map! ))) Such a relief ) @Matt Obert Thank you very very much for helping me out! Thank you for your time and your effort. What's also important thanks to you I have learned a few new tools.

4

UPDATE: I have verified that chmod 640 is still required for PHP files, even with version 62 of ide50. The quickest way to get all of the PHP files set from 600 to 640 is to execute the following command in the pset8 directory:

~/workspace/pset8/ $ find . -name *.php |xargs chmod 640

Once I did that, I started to troubleshoot the PHP issues. I'm not done yet, but here's a start:

search.php gave me an error because it could not open "/../includes/config.php" (on line 3)

I solved this by setting chmod 711 includes.

Next, config.php gave me an error because it could not open "../vendor/library50-php-5/CS50/CS50.php" (on line 20).

I fixed this by setting all the directories to chmod 711:

find . -type d |xargs chmod 711

But then I set the bin directory back to 700 for security, and because it is not used by the web app, only at the command line:

chmod 700 bin

Then I got this pair of errors:

Warning: file_get_contents(/home/ubuntu/workspace/pset8/includes/../config.json): failed to open stream: Permission denied in /home/ubuntu/workspace/pset8/vendor/library50-php-5/CS50/CS50.php on line 95
Fatal error: Could not read /home/ubuntu/workspace/pset8/includes/../config.json in /home/ubuntu/workspace/pset8/vendor/library50-php-5/CS50/CS50.php on line 98

The fix for that was to set the permissions on config.json to 640, same as PHP files:

chmod 640 config.json

So it seems that the permission errors are exactly the same as the ones that I documented on pset7, when version 59 of ide50 was first released. I apologize for taking so long to diagnose this properly, but I am just starting pset8 myself so I did not fully debug the issue until tonight!

By the way, if this answer helps you out, be sure to accept it by clicking the green check mark. Only the person who asked the question can do this, and if you don't the question will forever haunt the forums as a zombie question in the lists of unanswered questions.

UPDATE2: A few things: permission errors are related to update50, specifically upgrades to ide50 >= version 59. If you made it through pset7 without problems, you dodged a bullet!

Also, you are right that block formatting is not available in comments. That's why I updated my answer (and you can edit your question!) rather than continuing in comments. Also, because I can't post comments from mobile. :)

Finally, the "search permissions are missing on a component of the path" error means that all the directories in the path must be set chmod a+x. That includes the following directories:

/home/ubuntu/workspace/pset8/public
/home/ubuntu/workspace/pset8
/home/ubuntu/workspace
/home/ubuntu
/home
/

Note also that if it becomes necessary to change permissions outside of your home directory, you'll need to temporarily elevate your privileges to admin level by using the sudo command, e.g.:

sudo chmod 711 /home

If you're not familiar with sudo, it means "Set Userid to root and DO something." Think of it as a convenient safety feature, like you can't do anything potentially dangerous without saying the equivalent of "Simon Says do it."

UPDATE3: @Vitale: I'm going to ask you to run the following commands and paste the output into your original question so that you can format it as a code block. Do not paste the output into the comments. Edit your original question.

ls -l / |grep home
ls -l /home |grep ubuntu
ls -l /home/ubuntu |grep workspace
ls -l /home/ubuntu/workspace |grep pset8
ls -l /home/ubuntu/workspace/pset8
ls -l /home/ubuntu/workspace/pset8/public

Thanks in advance!

For your reference, this is what the output looks like for me:

MY PERMISSIONS (OK!)

~/workspace/ $ ls -l / |grep home
drwxr-xr-x   13 root root  4096 May 10 23:24 home/
~/workspace/ $ ls -l /home |grep ubuntu
drwxr-xr-x 22 ubuntu ubuntu  4096 Aug 16 20:55 ubuntu/
~/workspace/ $ ls -l /home/ubuntu |grep workspace
drwxr-xr-x 44 ubuntu ubuntu 4096 Aug 14 00:05 workspace/
~/workspace/ $ ls -l /home/ubuntu/workspace |grep pset8
drwxr-xr-x 7 ubuntu ubuntu    4096 Aug 13 23:27 pset8/
~/workspace/ $ ls -l /home/ubuntu/workspace/pset8
total 2688
-rw------- 1 ubuntu ubuntu 2705512 Aug 10 04:31 US.txt
drwx------ 2 ubuntu ubuntu    4096 Aug 13 23:27 bin/
-rw-r----- 1 ubuntu ubuntu     154 Aug 10 03:38 config.json
drwx--x--x 2 ubuntu ubuntu    4096 Nov  5  2015 includes/
-rw------- 1 ubuntu ubuntu     959 Aug 15 03:08 pset8.sql
drwx--x--x 6 ubuntu ubuntu    4096 Nov  5  2015 public/
-rw------- 1 ubuntu ubuntu    2371 Aug 10 04:31 readme.txt
drwx--x--x 3 ubuntu ubuntu    4096 Oct 26  2015 vendor/
~/workspace/ $ ls -l /home/ubuntu/workspace/pset8/public
total 32
-rw-r----- 1 ubuntu ubuntu  422 Nov  5  2015 articles.php
drwx--x--x 2 ubuntu ubuntu 4096 Nov  5  2015 css/
drwx--x--x 2 ubuntu ubuntu 4096 Nov  5  2015 fonts/
drwx--x--x 2 ubuntu ubuntu 4096 Nov  7  2014 img/
-rw-r--r-- 1 ubuntu ubuntu 1833 Aug 16 13:41 index.html
drwx--x--x 2 ubuntu ubuntu 4096 Nov  6  2015 js/
-rw-r----- 1 ubuntu ubuntu 2913 Aug 16 00:36 search.php
-rw-r----- 1 ubuntu ubuntu 1526 Nov  5  2015 update.php

These are my permissions, and everything (HTML, CSS, JavaScript and PHP) is loading fine. If your permissions really are the same, more drastic measures may be called for.

Here are your permissions, re-formatted from the comments below:

YOUR PERMISSIONS (NOT OK!)

~/workspace/pset8/ $ chmod a+x bin includes vendor
~/workspace/pset8/ $ ls -l
total 20
drwx--x--x 2 ubuntu ubuntu 4096 Nov 7 2014 bin/
-rw------- 1 ubuntu ubuntu 137 Nov 5 2015 config.json
drwx--x--x 2 ubuntu ubuntu 4096 Nov 5 2015 includes/
drwx--x--x 6 ubuntu ubuntu 4096 Nov 5 2015 public/
drwx--x--x 3 ubuntu ubuntu 4096 Oct 26 2015 vendor/

HERE IS ONE PROBLEM. You have set config.json to chmod 600. I know that's what they tell you to do in the problem specification, but the recent update has changed those permissions and the specifications have not yet been edited to reflect the change. You will need to set chmod 640 config.json to get things working with your database connection.

Other than that, this part is fine. You are setting chmod a+x just for some directories, which end up with appropriate permissions of 711.

~/workspace/pset8/public/ $ chmod a+x *

HERE ARE MORE PROBLEMS. You have set your PHP files to have the execute bit set for group and world, which is only appropriate for directories. Also, index.html does not need to have the execute bit set at all. You've got to be careful with the * and other wild-card characters!

~/workspace/pset8/public/ $ ls -l
total 32
-rwx--x--x 1 ubuntu ubuntu 422 Nov 5 2015 articles.php*
drwx--x--x 2 ubuntu ubuntu 4096 Nov 5 2015 css/
drwx--x--x 2 ubuntu ubuntu 4096 Nov 5 2015 fonts/
drwx--x--x 2 ubuntu ubuntu 4096 Nov 7 2014 img/
-rwxr-xr-x 1 ubuntu ubuntu 1823 Nov 5 2015 index.html*
drwx--x--x 2 ubuntu ubuntu 4096 Nov 6 2015 js/
-rwx--x--x 1 ubuntu ubuntu 374 Nov 5 2015 search.php*
-rwx--x--x 1 ubuntu ubuntu 1526 Nov 5 2015 update.php*

Yeah, these permissions are definitely wrong. Compare them with mine up above. The directories are fine, but the PHP files should look like rw-r----- (chmod 640) and index.html should look like rw-r--r-- (chmod 644). There may be other problems too.

LAST RESORT: There's one more option left open to us which might help. You can back up all of your files, delete your workspace and create a new workspace. But I don't recommend that you do this -- in fact, I won't even tell you how to do it until we take a closer look at your permissions.

I'm not absolutely certain that all your permissions are correct. I haven't seen evidence that you ran commands like find . -name *.php |xargs chmod 640 and find . -type d |xargs chmod 711 to set the proper permissions for everything in the pset8 directory recursively.

In fact, your comments below seem to indicate that you have set chmod a+x * which is wrong -- only directories need to have the execute bit set! PHP files need to be set chmod 640 and you have set at least some of them to chmod 711!

I know that you are frustrated, but please take the time to run the commands I asked you to run an hour ago. As you noted, it's very difficult to read the output of ls -l in the comments. I would greatly appreciate it if you could edit your original question to include the ls -l output in code block form, so that I can easily read it.

If that fails, I will explain to you exactly how to back up all of your work, nuke your entire workspace from orbit, and create a new workspace. But I can practically guarantee that it will not be necessary.

  • 1
    Thank you very much for your answer. According to spec cdn.cs50.net/2016/x/psets/8/pset8/pset8.html, bin, includes and vendor should have 700, while public directory should have 711. But I have followed your recommendation and set all directories within pset8 to 711, i.e. bin, includes, vendor and public. Unfortunately, I still get the same 403 Forbidden message. – Vitale Aug 14 '16 at 16:51
  • 1
    Thank you very much for such detailed answer and your help. It's great to learn more - I didn't know how to check apache's error log ) Still 403 Forbidden error with access to / denied message as you mentioned. In a few separate comments I will post three results of the error log check and permissions to files, which resembled your ones before I have added +x to all in the path - first, in the pset8 directory and than in the public directory. – Vitale Aug 15 '16 at 9:00
  • 1
    I would like to thank you again for your great help! I have studied your UPDATE and have followed your suggestions and checked permissions on all files, but this doesn't solve my 403 Forbidden issue. It seems that a problem can lie somewhere else, can't it? I did hope to dive into the pset8, but I can't even load the site for a third day in a row ) Interesting. Can it be some problem with my IDE settings? – Vitale Aug 15 '16 at 11:03
  • 1
    Thanks so much for your answer. You saved me days of struggling on this! – user13386 Aug 16 '16 at 14:54
  • 1
    @MattObert Please, see my updates of the original post. – Vitale Aug 17 '16 at 10:07

You must log in to answer this question.

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