0

I've read through every post I can find on the error message:
You don't have permission to access / on this server.

And I am not even sure what info to include. Definitely a newbie. Here's what I know. I am running Apache/2.4.16 on a Mac OSX Yosemite. At one point http://localhost returned "It works!". I then went to /etc/apache2, opened the file httpd.conf and removed the # (using MacRabbit Espresso) from the following lines:
LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule alias_module libexec/apache2/mod_alias.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so

I restarted apachectl. Everything still seemed to be working fine at that point. (Although I did not retest localhost).

Here's where the problem seemed to have started. I created a new file info.php. I placed it in "/Library/WebServer/Documents". I then tried "http://localhost/info.php". That's when the permission errors started showing up. And that is when my evil hacker side took over. I used Finder to change permissions in several subdirectories, basically adding Read & Write permissions to me. The one oddity is that the httpd.conf file has permissions for me, wheel, and everyone. But no permissions for "system." (No clue as to whether or not that matters.)

End result: I got the permissions error I wrote about above.

So where do I go from here?

1 Answers1

0

Be careful changing permissions on random files as you can do damage to your system or create security holes in your machine.

Apache on OSX uses /Library/WebServer/Documents/ as the document root and Apache has a special user for running the webserver (which I believe on OSX is _www).

What I would suggest is following the instructions on the accepted answer in this question (Correct owner/group/permissions for Apache 2 site files/folders under Mac OS X?) which gives a very good answer, otherwise this guide here goes through not only setting up Apache, but configuring it to have user-level document roots.

If you feel confident in working in the command line yourself, the answer is to make sure that _www is allowed to read and execute files contained in the document root and is the owner of the document root.

Community
  • 1
  • 1
Damon Swayn
  • 1,326
  • 2
  • 16
  • 36
  • I feel relatively confident with Terminal. I also ran a check and got the following error message for httpd.conf: 0526: Syntax error on line 221 of /private/etc/apache2/httpd.conf: Invalid command '\xc2\xa0AllowOverride', perhaps misspelled or defined by a module not included in the server configuration Any idea what that should be? Thank you. – Meilech Leib DuBrow Sep 08 '15 at 05:00
  • I looked at the document you referenced. I think the only difficulty I am having is identifying "each parent directory leading to your web root". Any tips/hints? – Meilech Leib DuBrow Sep 08 '15 at 05:06
  • First of all, `httpd.conf: 0526: Syntax error on line 221 of /private/etc/apache2/httpd.conf: Invalid command '\xc2\xa0AllowOverride',` means that you have inserted some invalid unicode characters into you config, remove the `\xc2\xa0` and you should be fine. In regards to each parent, I would ignore changing permissions on the parent directories if you keep using the default web root as these are system directories, Only configure the web root folder and all children of the web root. – Damon Swayn Sep 08 '15 at 06:06
  • I followed the instructions in the Link above (Correct Owner...) to correct the permissions problem. For the invalid unicode characters, I could not find \xc2\xa0, so I copied and pasted the three referenced lined from what I thought was an uncorrupted httpd.conf file. When I ran from my browser: http://localhost, I got an "Unable to connect error"? I've made so many changes now, I have no idea what's damaged. Any further suggestions? – Meilech Leib DuBrow Sep 08 '15 at 14:48
  • The "Unable to connect problem..." is solved, at least for the moment. First, I reset my user permissions to the system defaults. Then I simply replaced the likely corrupted httpd.conf file with the original. I was then able to get localhost to say "It works!" Unfortunately, I still don't know exactly what the problem was (or is) and what specifically solved it. Most unsatisfying. – Meilech Leib DuBrow Sep 08 '15 at 17:54