How to Install Miniserve on Ubuntu Server

Miniserve is a fast and easy-to-use static HTTP server that can be used to serve files in a directory over the internet. In this tutorial, we will explain how to install Miniserve on Ubuntu Server.

Prerequisites

Before you begin, make sure you have the following:

Step 1: Update the System

The first step is to update the system package list and upgrade the installed packages to their latest versions. To do this, open a terminal on your Ubuntu server and run the commands below:

sudo apt update
sudo apt upgrade

Step 2: Install Rust

Miniserve is written in the Rust programming language, so you need to install Rust on your system. To install Rust, run the following command:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

The command above will download and run a script that will install Rust and the Rust package manager called Cargo. After the installation is complete, you will need to log out and log back in for the changes to take effect.

Step 3: Install Miniserve

After installing Rust, you can now proceed to install Miniserve using the cargo package manager. Run the following command to install Miniserve:

cargo install miniserve

The above command will download and install Miniserve and its dependencies. The installation will take some time, depending on your internet connection and system speed.

Step 4: Running Miniserve

Once the installation is complete, you can start Miniserve by running the following command:

miniserve

This will start Miniserve with default settings to serve the current directory over HTTP on port 8080. You can visit the server IP address followed by port 8080 (e.g., http://your_server_ip:8080) on your web browser to see the files and directories being served.

Step 5: Adding Authentication

To add basic authentication to your Miniserve server, you can use the --auth option followed by a username and password. For example, to set the username to admin and password to password123, run the following command:

miniserve --auth admin:password123

Now, if you try to access your Miniserve server, you will be prompted to enter your username and password before you can proceed.

Conclusion

In this tutorial, you learned how to install Miniserve on Ubuntu Server and serve files over HTTP. You also learned how to add authentication to your server to restrict access to authorized users only. Now you can easily share files with others over the internet without the need for more complex file transfer protocols.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!