Web servers can be generalized into two segments; the ones for running dynamic sites with configured complexities like databases software and the ones for running a simple static web front-end.
Servy web server qualifies as an ideal candidate for running a simple/basic website with no backend/logic code attached to it.
This article will walk us through understanding and configuring the Servy web server so that you can be able to comfortably run your simple websites before associating them with a backend code.
Installing Servy Tiny Web Server in Linux
It is always a good idea for Linux users to ensure their systems are up-to-date through their respective package managers.
$ sudo apt install update [On Debian, Ubuntu and Mint] $ sudo yum install update [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ sudo pacman -Syu [On Arch Linux] $ sudo zypper update [On OpenSUSE]
Next, you need to clone the Servy repository using the following wget command.
$ wget https://github.com/zethra/servy/archive/refs/heads/master.zip
To extract the master.zip file we just downloaded, we need to make sure that the unzip package is installed on our Linux system.
$ sudo apt install unzip [On Debian, Ubuntu and Mint] $ sudo yum install unzip [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ sudo pacman -S unzip [On Arch Linux] $ sudo zypper install unzip [On OpenSUSE]
We can now proceed and extract the master.zip file containing the Servy web server.
$ unzip master.zip $ cd servy-master $ cd src
Since Servy web server is written in a rust programming language, programs written with this programming language have the .rs
extension as depicted on the above screen capture.
Installing Rust Programming Language in Linux
Before we can compile the rust file ~/servy-master/src/main.rs, we must first install rust programming language on our Linux systems.
$ sudo apt install rustc [On Debian, Ubuntu and Mint] $ sudo yum install rust [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ sudo pacman -S rust [On Arch Linux] $ sudo zypper install rust [On OpenSUSE]
Next, create the Servy web server executable using Cargo.
$ cd servy-master $ cargo build
After running the above command, you should note some changes in the main servy-master directory like the creation of the ~/servy-master/target/debug directory points to Servy Web server binary/executable file.
$ cd servy-master/target/debug
Running Basic Website Using Servy Web Server
We can run the web server from the servy-master directory with the following command:
$ ./target/debug/servy
The web server will start running on port 8000.
If you access the above URL from a browser, you will get its directory listing view.
Serving Basic Website Using Servy Web Server
You will need to point to the directory that contains the website pages Servy needs to serve. For instance, if your website files reside in /var/www/html directory:
$ ./target/debug/servy /var/www/html
The web view will be as follows:
The following command provides additional options on the usage of this web server.
$ ./target/debug/servy --help
Servy web server is ideal for web developers that want to perfect the responsiveness of their website projects on a development environment before migrating to a production environment. It is easy and faster to set up and uses minimal CPU resources.