Is there any webserver that supports CGI (not FastCGI/Rack/WSGI) and that is easy to setup? (lightweight and portable if possible, just need to copy the binary to another similar machine)

So I'll just need to put some CGI scripts there, and then when I visit that script using a browser, the script gets exectured and displayed in the browser.

OS: Linux

  • 2
    Take a look at XAMPP apachefriends.org. It has a portable version too.
    – Cornelius
    Commented May 8, 2014 at 7:58
  • sorry, I just edit my question, I prefer lightweight too, XAMPP just too big for me
    – Kokizzu
    Commented May 8, 2014 at 7:59
  • 1
    It is not portable, but it is lightweight: nginx tautvidas.com/blog/2012/01/…
    – Cornelius
    Commented May 8, 2014 at 8:26
  • umm.. thats FastCGI not CGI.. thanks anyway..
    – Kokizzu
    Commented May 8, 2014 at 8:39
  • 1
    Yes, Nginx counts as one of its (security) features that it cannot run CGI. Feature or not, few people care, since FastCGI typically far preferred over CGI. Commented May 8, 2014 at 8:42

4 Answers 4


I've used Acme Labs' thttpd - easy to set up, fast and supports CGI.

Most recently I put it one some Raspberry Pis.

It's a single binary, when you launch it you give it the name of a config file.


busybox can be built with http and cgi modules.

Let me quote the project's description:

BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete environment for any small or embedded system.

BusyBox has been written with size-optimization and limited resources in mind. It is also extremely modular so you can easily include or exclude commands (or features) at compile time. This makes it easy to customize your embedded systems. To create a working system, just add some device nodes in /dev, a few configuration files in /etc, and a Linux kernel.


uWSGI with CGI (only requires Python)

Install using:

curl http://uwsgi.it/install | bash -s cgi /tmp/uwsgi

create a setup configuration so you can run it without too many arguments, for example test.ini

http = :8081
http-modifier1 = 9
#uid = 
#gid =
check-static = ./www
static-skip-ext = .php
static-skip-ext = .rb
static-skip-ext = .py 
static-skip-ext = .lua
static-index = index.html
async = 16
ugreen = true
socket =
cgi = ./cgi
cgi-allowed-ext = .php
cgi-allowed-ext = .rb
cgi-allowed-ext = .py
cgi-allowed-ext = .lua
cgi-index = index.rb

create a testing script, for example ./cgi/test.rb

#!/usr/bin/env ruby    
require 'cgi'    
cgi = CGI.new
puts cgi.header
puts '<html><body>ENV: <ol>'
ENV.each do |k,v|
  puts "<li><b>#{k}</b> #{v}</li>"
puts '</ol>POST: <ol>'
cgi.params.each do |k,v|
  puts "<li><b>#{k}</b> #{v}</li>"
puts '</ol></body></html>'

start the server using:

./uwsgi test.ini

test it using browser or curl:

curl -d 'test2=2' localhost:8081/test.rb?test=1
  • 1
    curl http://.. | bash allows anyone in your local network to install arbitrary software on your machine.
    – phihag
    Commented Mar 30, 2017 at 14:46
  • Sending the response of an un-encrypted protocol to command interpreter is dangerous as @phihag explains. Use https where possible, or better yet, download the script, examine it first, before executing with the shell.
    – DannyNiu
    Commented May 27, 2021 at 1:18

I recommend ncat --exec. See https://nmap.org/ncat/guide/ncat-exec.html

Here is an example:

ncat --keep-open -p 5555 -l --exec /bin/bash

You can then make multiple interactive connections to a shell (or any other linux program that interacts through stdin/stdout) using telnet or nc:

$ nc localhost 5555
echo hi
  • You do realize the question contains the qualifier "... that supports CGI" do you? Do you have a reference where nc gains CGI support in some version? I don't think it has because nc is supposed to be used as a bare-bone user interface to sockets.
    – DannyNiu
    Commented May 25, 2021 at 8:03
  • I see now that this answer shows a way to interact with a shell remotely via a tcp socket (rather than say ssh), which can be useful but is not what the OP asked for.
    – masterxilo
    Commented May 26, 2021 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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