Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to make the contents of a folder available at http://localhost:PORT/, temporarily. A very basic http server.

I already know about,

 $ python -m SimpleHttpServer 

or ( this seems like the new way )

 $ python -m http.server 

but I'm looking for alternate command-line methods.

share|improve this question
@Stefan Are you looking for a way to temporarily host a given directory, or just looking for how to start webservers? (Your title and description don't seem to line up) – Michael Mrozek Nov 11 '10 at 15:29
@Stefan and what's in this folder? are you just looking to run something for development? production? if production did you have a certain server in mind (e.g. apache, nginx) – xenoterracide Nov 11 '10 at 15:31
Really wanted this to be community wiki, but it seems I dont have that option. Anyway, I clarified the question. – Stefan Nov 11 '10 at 17:34
@Stefan You can flag for mod attention if you think a post should be CW, but I'm not sure this actually should be. I'm not the best authority on the proper usage of CW though – Michael Mrozek Nov 11 '10 at 17:51
The question I had in mind was to be CW, but this has morphed into something else... – Stefan Nov 11 '10 at 17:56
up vote 4 down vote accepted

There is no such thing like a "system' webserver in unix and different "methods".

You can install software on your system which contains a simple webserver and use it or not.

python -m SimpleHttpServer just loads the SimpleHttpServer module, which contains a basic webserver.

Something simliar exists for Perl, just have a look at CPAN: http://search.cpan.org/dist/HTTP-Server-Simple/

"Simple" is a solution for Java: http://www.simpleframework.org/

The same can be really easy achived with JavaScript and nodejs: http://nodejs.org/api.html , see the section about HTTP.

Another solution would be to do it yourself: HTTP is a really simple protocol, when it comes to only serve some static files. To get /foo/bar your browser will request it with:

GET /foo/bar HTTP/1.1

The reply should be in the following form:

HTTP/1.0 200 OK
Last-Modified: Tue, 10 Jan 2010 11:11:11 GMT
Content-Type: text/html; charset=utf-8



HTTP/1.1 404 Not Found
Last-Modified: Tue, 10 Jan 2010 11:11:11 GMT
Content-Type: text/html; charset=utf-8


Include the Last-Modified header to enable caching of the ressources. It should be possible to write a minimal implementation of this in a few lines of code. Tie it to a port and you will have your webserver up and running. Use inetd or netcat to bind it to your IP.

Edit: Here is a simple shellscript which does exactly this job. It also supports generating an index for the folders and 404 error handling:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.