I am using a MacBook with OS X Mounain Lion 10.8.3 and I want to install a local web server on my machine. What are my options? On windows I used XAMPP.
-
I wouldn't install anything, but just turn it on... Here is a duplicate question with a decent answer. – beroe Oct 05 '13 at 05:33
4 Answers
If you just want something very quick, the OSXDaily article Create an Instant Web Server via Terminal Command Line explains how to do this on the command line using Python. Its pretty much just using the command:
python -m SimpleHTTPServer

- 9,875
-
-
Also note that the server will run on port
8000
by default, as ports below 1024 require superuser privileges. – Victor Sergienko Dec 29 '21 at 02:41
If you are interested in running Apache, PHP, MySQL and phpMyAdmin, you can check out this article.
Or just use MAMP

- 4,369
-
-
1We don't know what "best" means for you. If you have specific requirements please add them to your question by editing it. – nohillside Oct 03 '13 at 13:23
Most of the stuff you need is already installed by default, or can be added easily. There is a lot of material on the web about how to do this, this article seems to cover the basics.

- 100,768
As already mentioned, there is a simple XAMPP
like solution called MAMP
which comes as both a free and a paid version. The free version will suit most people. Just like XAMPP
this will provide you with Apache, PHP and MySQL, and also PhpMyAdmin/
If you just want to serve a simple html page, with no underlying PHP or anything you could use Python's SimpleHTTPServer, with the following bash
function that you can put in your ~/.bash_profile:
function servedir {
local port="${1:-80}"
open "http://localhost:${port}/"
sudo python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
}
With the servedir
bash
function, you simple change to the directory you want to serve, type servedir
and then it will open your web browser at http://localhost
so you can see your page.

- 286