Apache on Mac OS X

Discussion in 'macOS' started by tipem, Jan 29, 2008.

  1. tipem macrumors member

    Joined:
    Apr 20, 2007
    Location:
    Columbus, OH
    #1
    Hi guys,

    Mac OS X Leopard can easily run Apache through it's Web Sharing feature. However, if I do turn Web Sharing on, people anywhere in the world with my computer's IP address will be able to access some of my files. So, I need to edit my httpd.conf file and change some "Allow"s and "Deny"s around in the <Directory "/Library/WebServer/Documents"> node.

    So, I go into Terminal and type in nano /private/etc/apache2/httpd.conf (this is where my httpd.conf file is located: you can find this easily by running httpd -V, d'oh). It opens up the file, I change some Allows and Denys around in the node and I get this error when going to WriteOut (^O) the file:

    Hmm... so how do I write to my httpd.conf file if I don't have permission? I'm the only user on my Mac and I'm the first, master user. Soo... I should have permission to write this, shouldn't I? How do I fix this? Thanks!
     
  2. killmoms macrumors 68040

    killmoms

    Joined:
    Jun 23, 2003
    Location:
    Washington, DC
    #2
    You'll need to sudo that instance of nano. httpd.conf owned by root:wheel as I recall, and your first "master" user is not root, merely an admin-level user. You need to authenticate using sudo and your account password to edit that file. Then you'll be able to write it no problem.
     
  3. tipem thread starter macrumors member

    Joined:
    Apr 20, 2007
    Location:
    Columbus, OH
    #3
    [EDIT] I researched it and typed up my post, then you responded as I just posted this! Hehe, anyway. Thanks!!

    ----------

    Nevermind, this command worked:

    sudo nano -w +114 /etc/apache2/httpd.conf

    Perhaps I had to authenticate myself, since sudo requests a master password. I can now write to my httpd.conf successfully. I've tried numerous combinations of Allows and Denys, but how can I make it so ONLY I can view my Apache webserver running on my mac? I've tried stuff like

    Order deny,allow
    Deny from all
    Allow from localhost


    And

    Order deny,allow
    Deny from all
    Allow from my.computer.ip


    And also my routers IP which is what is displayed as I connect to the internet. So how I do I get the permissions straight in my httpd.conf to only allow myself to view my Apache webserver running on my Mac? I really dont want anybody else to be able to view my computer, I just want to use the Apache capabilities for developing PHP programs and such locally instead of FTPing a file every single time I edit something. It's annoying.
     
  4. adamswick macrumors newbie

    Joined:
    Jan 29, 2008
    #4
    Configure your router

    Your router should have settings for port forwarding. Make sure ports 80 and 443 do not point to your web server and you should be ok. Odds are that your router is issuing the IP for your computer and therefore your computer is not externally accessible. Your router's IP is externally accessible. Unless you have specifically forwarded requests for specific ports from the router to your machine, you should be completely covered, as your router acts as a firewall.

    Apache should work fine out-of-the-box with minor tweaks for PHP.

    If you DO want external access to your web server while in development, you might want to have your router do port translation from a nonstandard port to your computer at port 80. For example, you can configure requests for http://your.router.com:8909 to be forwarded to: http://192.168.1.2 (port 80 on your computer).
     

Share This Page