3

Even the (i) at the top right corner of IDE has disappeared along with the link to the server(or website). I started apache as specified in pset8 with correct permissions etc but am getting 403 Forbidden error on visiting the link.

The rest of the IDE is working fine, except that I can not access phpmyadmin and my server.

11
  • 1
    I have the same issue for 2 days. Pset7 that was functional before does also give 403 forbidden error. Seems like C9 IDE has changed.
    – eeagent
    Commented Jul 24, 2016 at 19:50
  • I have the same issue starting this week where I cannot see (i) on the upper right corner of the appliance. Starting now I have been constantly getting 403 forbidden error from the local host website.
    – meebox
    Commented Jul 27, 2016 at 22:51
  • 1
    I solved this by giving the execute permissions to the parent directory of the public directory (pset8 in case of problem set 8). That is /home/ubuntu/workspace/pset8/ $ chmod 711 .. For some reason, I didn't have to do this in problem set 7.
    – mimo31
    Commented Jul 28, 2016 at 7:30
  • @mimo31 ,your tricked worked but I am still not able to access phpMyAdmin. Do you have any workaround for that? Commented Jul 28, 2016 at 14:28
  • You can bypass the problem about phpmyAdmin just by refreshing the page. At least worked for me. You can reach the page from left top corner CS50 IDE -> phpMyAdmin
    – eeagent
    Commented Jul 28, 2016 at 16:18

4 Answers 4

9

Someone else posted some helpful solutions I will summarize here... I can't remember who (sorry).

From ~/workspace/

chmod -R 755 pset8

(or chmod -R 755 pset7 ... I had the same Forbidden error with pset7)

This opens up lots of permissions and could be security issue in real world, I imagine. But, if you need to get working on the pset...

Also, since they changed the layout and the username and password seem have disappeared from where the instructions tell us to find them. Use these in terminal:

username50

password50

To get your username and password that go in the config.json and used to login to your MySQL database.

5

See this post: Issues with the CS50 IDE

There have been updates to the IDE, and unless there's a new way to get there that I'm missing, there's a bug in accessing your own site through the IDE.

2

TL; DR: If you are having permission issues on pset7, you can fix them with the following three commands:

find ~/workspace/pset7/ -type d |xargs chmod 755

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

sudo find /var/lib/php5 -name sess_* |sudo xargs chown www-data:www-data

The Long Version:

There is definitely a problem with permissions on PHP sessions for apache50 in version 59 of ide50. Hopefully, the CS50 folks will fix this in the next version.

Meanwhile, the apache50 log files are accessible at /home/ubuntu/lib/apache2/log/ and you may get a better idea of what is causing this error by restarting the server and watching the error log file via tail -f ~/lib/apache2/log/error.log while trying to load a URL that gives you a 403 error.

Let's say you are having trouble loading pset7, like many of us were in my class tonight.

Restart Apache with apache50 stop && apache50 start ~/workspace/pset7/public and tail the error log in another Terminal tab.

Look for something like this:

[...] (13)Permission denied: [client 10.xxx.xxx.xxx:49208] AH00035: access to / denied (filesystem path '/home/ubuntu/workspace/pset7/public') because search permissions are missing on a component of the path

If you see the "search permissions are missing on a component of the path" error, then you need to make sure that all the directories in the full path to the server's root directory have the execute bit set for user and group. (Click here for the full explanation.) The Apache documentation recommends setting chmod 755, but trial and error have shown that chmod 710 will suffice.

At first, some of us were messing up our directories by setting overly-lax permissions recursively (i.e., chmod -R 755 ~/workspace/pset7 will help you to load the webpage, but it's overkill.) If you have done this, you can (and should!) restore your permissions to the least possible privileges necessary.

The quickest way to accomplish this is to pipe the output of the find command to xargs as shown here:

find ~/workspace/pset7/ -type d |xargs chmod 710

Then, just in case you have already changed the permissions on your PHP files to anything other than 600, use a similar trick to reset them:

find ~/workspace/pset7/ -name *.php |xargs chmod 600

Finally, even after you have fixed the permissions on your files and directories, you may still have a problem with the PHP session files, as we did tonight:

[...] PHP Warning:  session_start(): open(/var/lib/php5/sess_8o5fbcbb416acoorfj80egd6p0, O_RDWR) failed: Permission denied (13) in /home/ubuntu/workspace/pset7/includes/config.php on line 24
[...] PHP Stack trace:
[...] PHP   1. {main}() /home/ubuntu/workspace/pset7/public/index.php:0
[...] PHP   2. require() /home/ubuntu/workspace/pset7/public/index.php:4
[...] PHP   3. session_start() /home/ubuntu/workspace/pset7/includes/config.php:24
[...] PHP Warning:  Unknown: open(/var/lib/php5/sess_8o5fbcbb416acoorfj80egd6p0, O_RDWR) failed: Permission denied (13) in Unknown on line 0
[...] PHP Stack trace:
[...] PHP   1. {main}() /home/ubuntu/workspace/pset7/public/index.php:0
[...] PHP   2. require() /home/ubuntu/workspace/pset7/public/index.php:4
[...] PHP   3. redirect() /home/ubuntu/workspace/pset7/includes/config.php:31
[...] PHP Warning:  Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php5) in Unknown on line 0

If you see this warning about session.save_path, run ls -l /var/lib/php5 and look for the session referenced in the error log. You may find that it is owned by user and group ubuntu:ubuntu. If so, this is part of the problem.

A temporary band-aid solution would be to sudo find /var/lib/php5 -name sess_* |sudo xargs chown www-data:www-data so that the apache50 process will have appropriate permissions for the session.

Unfortunately, the real solution is to wait for the ide50 maintainers to correct the permission problems, and then run update50 again.

EDIT: (because I can't comment on mobile!)

@Dash: Are you sure you need to chown your PHP session file? Are you actually seeing the warning about session.save_path? I think they fixed this part of the bug with update50 after ide50 version 60 or so.

1
  • 1
    Thank you for this answer. Unfortunately, when I attempt to run the sudo find /var/lib/php5 -name sess_* |sudo xargs chown www-data:www-data I get the following error: chown: missing operand after ‘www-data:www-data’ Any advice? Commented Aug 26, 2016 at 22:37
1

I solved the problem today by giving "chmod 644" permission to .php files instead of 600. That however did not work yesterday when I was forced to give up.

1
  • Try chmod 640 for PHP files and config.json instead of chmod 600. If you can keep the world-level permissions locked down and restrict sharing to user and group, that's a big win for security. Commented Aug 5, 2016 at 23:08

You must log in to answer this question.

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