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

ksb43

macrumors member
Original poster
Oct 15, 2008
33
0
Hey. Typically web sharing (found in the Sharing section of system prefs) allows other computers to access your "/Users/[username]/Sites/" directory. However I have MAMP installed so my local sites have to exist in the "/Applications/MAMP/htdocs" directory. Is there anyway to make the web sharing directory point to this one instead?

I found this:
http://support.apple.com/kb/TA25038

And I tried changing the path in my [username].conf file to:
<Directory "/Applications/MAMP/htdocs">

And I did this command in terminal (anyone knows what this is doing btw? is it just locking the privileges on this file?):
sudo chown root:wheel /etc/apache2/users/[username].conf

But when I try to go to my site http://[ipaddress]/~[username]/ i can't access anything. I get a 404 page cant be found error.

Any suggestions? Thanks!
 
Well, Web Sharing is essentially just turning Apache on (the default install one, not the MAMP one). When you startup MAMP you're turning on Web Sharing for the most part. Once it's started people on your network should be able to enter your IP and get your main page in MAMP/htdocs/. There's no need for the ~user part.
 
chown is CHange OWNer. Most of /Library is owned by user root of group wheel, so the command is just bringing your config file in line with the rest.

I've never dealt with a preconfigured MAMP package, just installed PHP and MySQL from source. However, I can change the root directory by editing /etc/apache2/httpd.conf , specifically the line that begins with DocumentRoot and then later one that says <Directory "/whatever/path"> , with a comment before saying to update the line when changing DocumentRoot. You may not have permissions to edit, in which case you can go into Terminal and edit it with

sudo nano /etc/apache2/httpd.conf

Angelwatt, http://localhost by default goes to /Library/WebServer/Documents, and http://localhost/~username goes to /Users/username/Sites.
 
Changing the httpd.conf file seems to work. I can now access the directory from another machine. However, it doesn't appear that it's working as a web server. IE6 is trying to download the PHP file instead of displaying it and Firefox is displaying the source.

I have MAMP running on the mac and web sharing turned on. Any idea why its not displaying this as a webpage?

Thanks!
 
Angelwatt, http://localhost by default goes to /Library/WebServer/Documents, and http://localhost/~username goes to /Users/username/Sites.

For the pre-installed Apache yes, but for MAMP no.

ksb43 said:
I have MAMP running on the mac and web sharing turned on.
You only need MAMP running. Having Web Sharing also checked can cause conflicts. Also, depending on any configuring you may have done with MAMP I believe it starts up on port 8080, so reaching it would require entering:
Code:
http://yourIP:8080/
or
Code:
localhost:8080
 
Changing the httpd.conf file seems to work. I can now access the directory from another machine. However, it doesn't appear that it's working as a web server. IE6 is trying to download the PHP file instead of displaying it and Firefox is displaying the source.

I have MAMP running on the mac and web sharing turned on. Any idea why its not displaying this as a webpage?

Thanks!

Sounds like a MIME type issue. You need .php to be seen as application/x-httpd-php . MAMP may deal with types elsewhere, but you should just be able to add the line

application/x-httpd-php .php

to the file /etc/apache2/mime.types
 
Looks like you were both right. The port for my MAMP was 8888 so I tried http://[ipaddress]:8888 and after it asked me for my username/pword, it worked! I didn't try setting the MIME type, since I can just do it this way for now. Thanks for the help guys!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.