Make another folder available for "Web Sharing"

Discussion in 'Mac Basics and Help' started by ksb43, Apr 30, 2009.

  1. ksb43 macrumors member

    Joined:
    Oct 15, 2008
    #1
    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!
     
  2. ksb43 thread starter macrumors member

    Joined:
    Oct 15, 2008
    #2
    Actually i'm getting 403 forbidden errors when I go to

    http://[ipaddress]/~[username]

    Not sure where the other 404 i got was from.
     
  3. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #3
    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.
     
  4. BlueRevolution macrumors 603

    BlueRevolution

    Joined:
    Jul 26, 2004
    Location:
    Montreal, QC
    #4
    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.
     
  5. ksb43 thread starter macrumors member

    Joined:
    Oct 15, 2008
    #5
    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!
     
  6. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    For the pre-installed Apache yes, but for MAMP no.

    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
     
  7. BlueRevolution macrumors 603

    BlueRevolution

    Joined:
    Jul 26, 2004
    Location:
    Montreal, QC
    #7
    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
     
  8. ksb43 thread starter macrumors member

    Joined:
    Oct 15, 2008
    #8
    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!
     

Share This Page