Skip to content
Serve files via HTTP from local directory
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Local Webserver

Build Status

This repository provides local webservers which serve the local directory in which they were stored.


If the server is stored at /home/user/tmp/directory.d/<server> it will serve all files in /home/user/tmp/directory.d/.

After starting the server a web browser should be started automatically. You can choose an interface the server should listen on, on startup.

To open the browser with the url, open is used on Mac OS X, start under Windows and xdg-open on Linux/Other operating systems.

You may want to use local_webserver to

  • share data on demand from your local machine without the hassle of filesystem permissions or setting up a network share
  • serve a local presentation – e.g. middleman-presentation
  • load data from your local machine onto some network device

What makes local_server so nice and sweet?

  • It's just one single executable
  • It has just a few options and does not use a configuration file
  • It can be compiled for multiple platforms - e.g. Mac OS X, Windows and Linux
  • It chooses a random port on startup, so there's no conflict with other instances of local_server – can be overridden
  • You can choose which interface the server should listen on.


The server will ask you what interface it should use on startup. If you do nothing and wait 7s or press ENTER will be chosen.


# Start server with random port (1023 < port < 65535) and localhost as interface and be verbose

# Start server with port and interface defined
<server> --port 1234 --interface

# Serve a different directory
<server> --directory /usr/share/doc
<server> --directory ~/

# Do not output anything
<server> --silent


% ./server.linux.amd64
Open browser with
Server listens on

Requests: - - [26/Nov/2014:14:34:10 +0100] "GET / HTTP/1.1" 200 41 "" "Mozilla/5.0 (X11; Linux x86_64; rv:33.0) Gecko/20100101 Firefox/33.0"

Pre-Compiled Binaries

There are pre-compiled binaries available. Just head over to the releases page


This project was built with Google Go. See this page for a good introduction for a Go-installation which can compile Go-binaries for multiple operating systems - tested on Archlinux (64bit) only.


  • Go needs to be installed
  • upx needs to be installed. Your version of upx needs to be able to compress 64-bit executables (Version >= 3.91). If you set COMPRESS=0 there's no need to install UPX.
  • make needs to be installed.
  • Bourne (compatible) shell needs to be installed.
  • rsrc needs to be installed

Configure shell

This is optional and highly opionated. Just make sure the go path is set correctly.

.bashrc / .zshrc

export GOPATH=~/.local/share/go-packages
export PATH=~/.local/share/go/bin:$PATH
export PATH=~/.local/share/go-packages/bin:$PATH

Define path where to install go build environment

export go_lang_install_path=~/.local/share/go

Clone repository

After that pull the sources of Go. This might take a while.

git clone $go_lang_install_path
git checkout go1.5.1

Install required operating system packages

On Arch Linux you need to run the following command to install the gcc-go-compiler and please make sure you follow all relevant instructions found in the Go Install Manual{: .fe-external-url target="_blank" }.

sudo pacman -S gcc-go upx make

Prepare "go" to build for all wanted platforms

After you ran all those commands, you will be able to build local_webserver for Linux, Windows and Mac OS X.

# Switch to src-directory
cd ${go_lang_install_path}/src

# Make go-binaries
GOOS=windows GOARCH=amd64 GOROOT_BOOTSTRAP=/usr ./make.bash
GOOS=darwin GOARCH=amd64 GOROOT_BOOTSTRAP=/usr ./make.bash
GOOS=linux GOARCH=amd64 GOROOT_BOOTSTRAP=/usr ./make.bash

Or just use this snippet

# Checkout most recent version
git checkout tags/<current_version>

# Build environment and disable CGO
for i in darwin linux windows; for j in 386 amd64 arm; do
  CGO_ENABLED=0 GOROOT_BOOTSTRAP=/usr/lib/go GOROOT=$HOME/.local/share/go GOOS=$i GOARCH=$j ./make.bash

Clone local webserver

Bootstrap application

This will install all required Go-modules. It will also check if all required other software packages are installed.

cd local_webserver

Create build directory for "local_webserver"

Now you need to create a build directory for local_webserver.

# Create directory
mkdir -p build_local_webserver

# Switch to directory
cd build_local_webserver

Pull sources of "local_webserver"

# Clone repository
git clone

# Switch working directory
cd local_webserver

Boostrap environment for building "local_webserver"

To check if everything is installed, run scripts/ This will also install all required go-modules.


Build application

To build the software you need to run the following command. This will create the executable files for Windows, Linux, Mac OS X which are also compressed using UPX.


After that is finished, you will found three executable files in the "build"-directory.

  • Windows 64-bit:
  • Linux 64-bit: server.linux.amd64
  • Mac OS X 64-bit: server.darwin.amd64

Default options

: ${OS:="windows linux darwin"}
: ${ARCH:=amd64}
: ${SOURCE_FILES:="server.go"}
: ${COMPRESS:="1"}

If you want to create executables which are not compressed and are only built for Windows, run the following command.

COMPRESS=0 OS=windows ./

Use make to run scripts

There's also a Makefile available.


make build

Bootstrap for CI

make bootstrap_ci


make bootstrap

Overwrite options

All options available in the shell-scripts are available in the Makefile as well. The only difference: They are all lowercase. To get a list of all available options look here.

# Disable compression of executables
make build compress=0

# Build for windows only
make build os=windows


Fix compress executable error

If you see CantPackException: can't pack new-ex you might need to update your upx. Older versions are not capable to pack 64-bit executables. I'm using upx 3.91 which works fine.

Known Issues


If you try to build and compress 64-bit binaries for Darwin/Mac OS X this will now succeed. It will fail with an UnknownExecutableFormatException-error. Unfortunately that seems to be a problem of UPX + Go Binaries.


Please see the

You can’t perform that action at this time.