MacOS – How to set a web server in a specific directory in OSX Mavericks

apachemacos

I am running a web server in OSX Mavericks using the default directory location ($HOME/Sites). How can I add sites from distinct arbitrary directories ?

I have found instructions about how to change the root folder of the apache server, but I do not want to override the default location (I have things there) but to add new folders.

Best Answer

This might be overkill, or answering a slightly different question than you asked, but if you have npm, you can

npm install http-server

and then just

http-server

from the directory you want to host. http-server will reply with the path hosted and the port it is hosted on e.g.:

Starting up http-server, serving ./foo on port: 8080 Hit CTRL-C to stop the server

If you launch multiple instances it will increment the port.