I want to install phpMyAdmin on the native Apache webserver that is bundled with Mac OS X 10.6. I turned on Web Sharing in System Preferences. Yet, me fear is that my computer is granting access to everyone on the web.
-
Where are the user access restrictions for the Web Sharing / Apache webserver within Mac?
-
How to I restrict access for all computers except my own so that I can run applications on the localhost webserver (like phpMyAdmin).
Best Answer
As has been pointed out already, unless you are specifically forwarding http traffic from your router to your machine, your locally hosted stuff will only be available to you and the other computers on your local network.
To answer your question on restricting access to your webserver to just your machine. You can do this a couple of ways.
Remember, anytime you change apache configurations, you need to restart apache for those changes to take effect.
Method 1
If you want to limit everything on your local webserver to just your local machine, edit the file "/etc/apache2/httpd.conf". At approx line 195 you'll find a configuration block that looks similar to:
You are going to want to comment out the bottom two lines of that block and add in new rules
and
that block should now look like:
Method 2
You can also use .htaccess files to limit who has access to a directory. In order for .htaccess files to work you first need to enable them. Open the same file I referenced in method 1 (/etc/apache2/httpd.conf) and go to the same configuration block I mentioned before (at approx line 195). You'll need to change (at approx line 215):
to
Once you have done that you can create a file called .htaccess in any folder on your web server with the following information:
That will prevent anyone besides your local machine from accessing the contents of that folder or any of it's subfolders.
Conclusion
Method 1 has the benefit of not having to worry about accidentally deleting .htaccess files or worrying about multiple configurations. Method 2 makes it very simple to only restrict access to certain directories of your webserver.
Also note that the .htaccess file must include that period at the beginning of the file name (it's .htaccess not htaccess) and that when you want to view your local webserver you have to do so by going to http://localhost (you can't use [your computer name].local).