5 ways to create an instant lightweight web server with Linux command line

You can create a simple and lightweight  web server very easily to test some code, serve files or whatever you like. No need of a full blown web server like apache or nginx, few lines of command will be fine to do this job.

Lets do it in 5 different ways !


1. instant python web server

Python is pre installed in almost every UNIX or GNU/Linux distributions, packs many feature reach modules inside it. Python commands could be used as an web server very easily.

For r python 2.7.x versions use this command .

python -m SimpleHTTPServer port_number 

Replace the port_number with port number of your choice.

python -m SimpleHTTPServer 8080 

To start a python web server on port 8080, by default it binds port 8000 with all available network interfaces .

note: Binding any port number bellow 1024 requires root privilege, in such case use sudo before the command . If there is a index.html file at that folder, it will be served by default, else contents of that directory will be served.

For python 3.x version use this command.

 python -m http.server 

test: Open up your favorite web browser, type 127.0.01:8000 in the URL bar and hit enter .

python web server


2. busybox httpd web server

Busybox, The Swiss Army knife of Embedded Linux, packs many stripped-down UNIX tools inside a single static executable binary. It runs on most UNIX/Linux systems and pre installed in all Debian based distributions. Busybox have an awesome feature rich HTTP server applet, busybox httpd , very simle and lightweight but also configurable enough. Download latest busybox and read more about here.

busybox httpd --help # show available options

busybox httpd -p -h /var/www/  # start start httpd

pkill busybox  # to stop busybo httpd

note: by default busybox httpd binds port 80 with all available network interfaces and reads /etc/httpd.conf configuration file .


3. webfsd HTTP server

Webfs or webfsd is a very lightweight and simple HTTP web server for static pages and files. It is highly configurable, webfsd configurations are stored at the /etc/webfsd.conf file, which could be very easily edited.

sudo apt-get install webfs  # install webfs in Debian/Ubuntu

sudo service webfs start  # start the webfs server


note: By default webfsd binds port 8000 with all available network interfaces with /var/www/html as document root folder in Debian.


4. netcat as a simple web server

Netcat or nc, the swiss army knife for TCP/IP , is a very popular network troubleshooting tool. It could be used as  port scanner, port listener, file transfer agent, network connected file backup tool, as a backdoor even as a vary basic web server, Amazing ! Netcat based web server is mainly used for serving text only files over HTTP, useful in monitoring purpose. Assuming you have basic shell scripting knowledge, lets start a simple HTTP server with netcat. Save the script bellow with whatever name you want , modify it according to your needs, make it executable with chmod +x and run it .

while true; do
echo -e "HTTP/1.1 200 OKnn $(cat /var/www/index.html)" |
nc -lp 1500 -q 1
sleep 1

You may want to chaneg the line cat /var/www/index.html with whatever you want to do , like /sbin/ifconfig eth0 etc. etc. If the sleep 1 line is removed, it will be difficult to stop the script with CTRL+C .


5. php inbuilt web server

If you have installed php 5.4 or above, then you could easily use the php CLI to create a simple and lightweight web server with. It also have the capability of serving simple php based dynamic pages. simply use the command bellow .

 php -S 

If there is a index.html or index.php file , it will be server by this simple php server , now test it with your favorite web browser.


I think now your problem is solved, if you need any further assistance just drop a comment, we’d be happy to assist you. Feel free to share this tutorial with your friends.

4 Responses

  1. sayantan says:

    Nice web site dude ……..carry on

  2. miguipda says:


    The menu About – Contact us answer that you are not reachable telling that I must use another way to contact you. Then I used this concerned form.


    Big challenge – Personal Cozy cloud on OpenWRT

    by considering the fact that OpenWRT must not be compile with needed packages could you please consider and make a tutorial of how do install Cozy cloud on OpenWRT ?

    You must know it needs node.js but it is better to use Light Cozy that allow to just add what it is needed :
    Light Cozy : https://cozy-labs.github.io/cozy-light/
    Full cozy : https://cozy.io/en/

    Have a nice day,

    Miguipda 😉

    • Arnab says:

      Good to see you again, a long time. What a coincidence, I’m thinking about writing a tutorial about running Node.js on OpenWrt Routers. Surely I’ll write how to setup Light Cozy on OpenWrt as soon as possible. Node.js packages are currently not available on OpenWrt repo so we’ll have to build it.

      Doing such experiments in constrained environment is damn tough, laptop with 40GB HDD!(after 1TB crashed) and 1.5GB monthly download+upload bandwidth quota, seriously !

      Oppps,, sorry about the contact form, that’s some PHP related issue while sending mail from the hosting server and I’m not a PHP expert to solve this issue. Mail me to as.work0(at)gmail.com .
      Btw, I’hd sent a mail to your mail address(which you filled in the comment form) to wish you christmas.

  1. April 12, 2016

    […] I didn’t have any choice cirros image doesn’t come with many goodies. Try this link if you are interested in experimenting with other simple web server. My server uses Linux Netcat […]

Leave a Reply

Your email address will not be published. Required fields are marked *