Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

netytan

macrumors 6502
Original poster
May 23, 2004
254
0
Hey guys,

Run into my first real problem with Mac! And i just can't fix it, which isn't really common for me so its a little anoying ;).

Anyway. The problem occurs when i try to access my "Sites" directory from the web browser - http://localhost/~mark/ - which basically throws a great big Forbidden aka 403 error message. Something that shouldnt happen if i am to believe the articles at:

http://www.macdevcenter.com/pub/a/mac/collections/webserving.html

Since everything should be configured. Nether the less I've checked the Apache config file and everything looks in order :confused: and the file permisions for the Sites directory seem to be correct at 775 (drwxrwxr-x).

Any clues would be much appreciated! This one has me stumped and i can't find anything of use on google :(. If this is a problem with OSX 10.3.4 then maybe i should ring tech help and report it?

Thanks guys,

Mark.
 

mkrishnan

Moderator emeritus
Jan 9, 2004
29,776
15
Grand Rapids, MI, USA
Have you opened the web ports in your firewall? IIRC when I used Apache this way on my PC, even though nothing leaves your PC, you are required to open the ports, at least to that specific IP address....
 

abhishekit

macrumors 65816
Nov 6, 2003
1,297
0
akron , ohio
You will have to turn the personal web sharing on, under system prefs-sharing. It should work. It would also show you the address of your page there.

cheers
 

tomf87

macrumors 65816
Sep 10, 2003
1,052
0
Also check you permissions on the files in the directory. They should be 644 (or rw-r--r--).
 

netytan

macrumors 6502
Original poster
May 23, 2004
254
0
Thanks for the quick replies guys!

abhishekit, personal web sharing is turned on on and i can see localhost without a problem, so the port is definatly open :(.

The problem is I can't see the Sites directory, (or the cgi-bin for that matter). I tried creating a test account to see if it was something i did to stuff things up but i get the same problem.

Any other ideas?

Im just looking over the error & access logs now, if that would help i can post them here?

Mark.
 

Thom_Edwards

macrumors regular
Apr 11, 2003
240
0
MacDevCenter from O'Reilly

try this link to the Mac Dev Center. this site has helped me to fix countless little problems like you are describing, and not just with apache. i *strongly* recommend anything with the o'reilly name on it.

also, are you trying to access just html pages? or are you using cgi or php? i believe there is some extra configuring in httpd.conf that must be done for it to work. (if i recall, these changes are discussed in one of the articles from the link above.)

good luck!
 

netytan

macrumors 6502
Original poster
May 23, 2004
254
0
tomf87 said:
Also check you permissions on the files in the directory. They should be 644 (or rw-r--r--).

Yup, the file has read permisions set.
 

netytan

macrumors 6502
Original poster
May 23, 2004
254
0
Thom_Edwards said:
try this link to the Mac Dev Center. this site has helped me to fix countless little problems like you are describing, and not just with apache. i *strongly* recommend anything with the o'reilly name on it.

also, are you trying to access just html pages? or are you using cgi or php? i believe there is some extra configuring in httpd.conf that must be done for it to work. (if i recall, these changes are discussed in one of the articles from the link above.)

good luck!

Just html, i will be setting up CGI and PHP pretty soon but seemed pointless since i cant even view my Sites directory :D. Will check out the link now, thanks much!

Edit: Saddly no luck, i've already looked at these a few times, in the article on setting up for isntance they dont experiance any such problems :(. And i've followed this article to make sure did things right; turns out that i did... so things should be working :mad:

Mark.
 

sonofslim

macrumors 6502a
Jun 6, 2003
742
0
in your /etc/httpd/httpd.conf file, look for a chunk similar to the following. if you're using the default httpd.conf that ships with Panther, it'll have a lot of commented lines (lines that begin with the # character) but the active code will follow this format.
Code:
<Directory "/Library/WebServer/Documents">
   Options Indexes FollowSymLinks MultiViews
   AllowOverride None
   Order allow,deny
   Allow from all
</Directory>

your settings may be different, based on how you set up your Apache configuration; if you followed macdevcenter's guidelines, you've probably got them set pretty tight. if your settings are like the above (Order allow,deny and Allow from all) then you're letting in all requests, and your problem lies elsewhere. but if your settings look like this:
Code:
Order deny,allow
Deny from all
then you're denying all requests by default, and you need to specify what IP addresses are allowed to make requests. if you don't see this line:
Code:
Allow from 127.0.0.1
add it at the end, just before the </Directory> tag. this says "let in requests that come from my computer."

if you're using a router or external firewall (say, in-home or office networking) also add the following line:
Code:
Allow from 192.168.1
(that's assuming you're using standard network IP addresses.) this lets in requests that get passed through your router, which might be the case if you type in your local IP or your computer's rendezvous name instead of "localhost".

by the way, a more concise description of access control via httpd.conf can be found here: http://www.macdevcenter.com/pub/a/mac/2003/04/22/apache_jaguar_pt3.html
 

Thom_Edwards

macrumors regular
Apr 11, 2003
240
0
... too early ...

wow, i must have still been asleep when i read your original post! i see now that you had already checked out mac dev center. sorry....

here is what i do, and you may want to try it. forget about home directories as far as the webserver goes. put your page in /library/webserver/documents and it should work (since you said going to http://localhost worked fine). if you have several users on your machine, you can always create a folder named mark (and any other users) in the documents dir.

i realize this doesn't really fix your problem, but it is certainly a viable workaround (imho). i've never been too keen on the whole /~username stuff for a web address. a lot of (everyday) people don't even know where to find ~ on the keyboard! and if you are only using your machine as a production server that is not too open to the public, you shouldn't have to worry too much about where the file sits as long as it works. get the pages working, then worry about configuration and file placement on the live server once you get there.
 

sonofslim

macrumors 6502a
Jun 6, 2003
742
0
duh

Thom_Edwards said:
here is what i do, and you may want to try it. forget about home directories as far as the webserver goes. put your page in /library/webserver/documents and it should work (since you said going to http://localhost worked fine).

duh for me... yay for Thom. my instructions are for /Library/WebServer/Documents, not your ~/Sites folder. i keep my sites in /Library/WebServer/Documents/ and i'm happy with the arrangement.
 

netytan

macrumors 6502
Original poster
May 23, 2004
254
0
Of course i could do that although since this should work i would really prefer to do it this way. If only because it helps sperate user accounts and gives each user more controle. But *nix users are used to this setup and its very likly that any colleges i will be going to next yr (still sorting that stuff out) will use this notation with their web servers.

Anyway i'm using the default config:

Code:
<Directory "/Library/WebServer/Documents">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Code:
<Directory "/Users/mark/Sites/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

I did originally set up CGI and PHP but reverted back to the default config when i found this problem.

Thanks for all the help guys, very very much apreciated!

Mark.
 

garybUK

Guest
Jun 3, 2002
1,466
3
Im having this problem on FreeBSD 5.2.1 as well, I was able to browse directories fine in BSD 4.9 Stable, but since upgrading unable to. I have been through my config file and no luck... i resorted to wacking in a custom php file that acts just like the default directory index .. http://81.97.1.14/~gary/files/

if you do find a way let me know.

Thanks.

Gary.
 

netytan

macrumors 6502
Original poster
May 23, 2004
254
0
garybUK said:
Im having this problem on FreeBSD 5.2.1 as well, I was able to browse directories fine in BSD 4.9 Stable, but since upgrading unable to. I have been through my config file and no luck... i resorted to wacking in a custom php file that acts just like the default directory index .. http://81.97.1.14/~gary/files/

if you do find a way let me know.

Thanks.

Gary.

Sorry, kinda comfused. Your ~ works fine for me? OSX is based on BSD is it not guys, could this be a problem resulting from the upgrade i did to 10.3.4.
 

garybUK

Guest
Jun 3, 2002
1,466
3
yes the ~gary/ works because i have placed a default .html/.php file there, but if there is no default file, the webserver should generate its own Index file of the directory!! this is where its showing forbidden......

So you ONLY get the forbidden message if there is no index.html / index.php file present!

try http://81.97.1.14/

Gary
 

netytan

macrumors 6502
Original poster
May 23, 2004
254
0
Eeep, this just got worse. I do have a default index.html file in there :eek:. Still getting this damn problem lol. Least i got somone to share the anoyance with ;). I'll find it eventually im sure and i'll be sure to let u know!
 

netytan

macrumors 6502
Original poster
May 23, 2004
254
0
PROBLEM SOLVED

Ok, i found the problem for anyone who is interested. The reason i was getting a 402 error was all because of file permisions would you believe it!!!

Apparently by default the directories Users and Mark dont have an x bit at the end (instead they have a t... but since i dont know what that is i just chmod'd to 755 and everything sorted itself out.

Not sure if this will help you though Gary :(.

Thanks for all your help, thats to everyone!

Mark.
 

abhishekit

macrumors 65816
Nov 6, 2003
1,297
0
akron , ohio
I just saved this macrumors webpage on my desktop, renamed it as index.html and put it in my sites folder. And I can access it just fine at the link indicated below web sharing option, in system prefs, which is http://dexmus.uanet.edu/~abhishek/
And I haven't configured apache, as I use tomcat for all my purposes. So it should work for you too
:confused:
EDIT: you did it :D
 

jeremy.king

macrumors 603
Jul 23, 2002
5,479
1
Holly Springs, NC
netytan said:
Ok, i found the problem for anyone who is interested. The reason i was getting a 402 error was all because of file permisions would you believe it!!!

Apparently by default the directories Users and Mark dont have an x bit at the end (instead they have a t... but since i dont know what that is i just chmod'd to 755 and everything sorted itself out.

Not sure if this will help you though Gary :(.

Thanks for all your help, thats to everyone!

Mark.

I thought you already checked those? :rolleyes:

Its important to note that if you expect a webserver to traverse directories, and that webserver is using another user account (most use a user called apache), then the directory and all those above it need execute permission for other.
 

netytan

macrumors 6502
Original poster
May 23, 2004
254
0
LOL, i checked all the ones that it made sence to check. I mean, surly it makes sence that the User dir would have +x by default ;). In any case, i wont make that mistake again!!!

Mark.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.