Group members:
-
Kaisar Kertarajasa
-
Satya Rayyis Baruna
-
Nadim Rafli Hamzah
In this project, we are making a simple web server written in Python, running on a FreeBSD virtual machine. Here, we are going to demonstrate a network communication between two hosts (Linux desktop and a FreeBSD guest VM) using TCP connection. The Linux desktop acts as a client while the FreeBSD guest VM acts as the server to handle client's request.
monospaced
fonts indicate terminal commands, file names, paths, package names, modules, source code, and URLs.
There are several reason why do we choose FreeBSD as our server operating system:
-
FreeBSD is a free and open source operating system, which complies to our project requirement that insist for the usage of free and open-source software.
-
FreeBSD is a lightweight operating system so that it does not utilize too much system resources so it can run smoothly in our virtual machine without giving excessive load to the host system.
-
FreeBSD is a stable, mature, and robust operating system which makes it suitable for a server operating system with good performance and security.
-
FreeBSD is well documented. The documentation can be read on the FreeBSD handbook.
For more information about FreeBSD, please refer to its official website.
Python is used to program the server as its ease of learning and compatible on multiple platforms. Python exhibits a plethora of library and frameworks, including a socket
library to make TCP connection between client and server possible. Using Python, a consise, lightweight, simple web server program can be made.
-
First, we have to install FreeBSD in a virtual machine. This time, we are using VirtualBox to do this task.
-
Install the operating system. In this
README.md
, we are not going to discuss FreeBSD installation in depth. Make sure to follow every step of installation. If you are on doubt, you may choose the default option, or please refer to the installation guide.Note: make sure IPv4 and DHCP configuration is enabled for the chosen network interface.
-
In the FreeBSD guest VM, make sure Python is installed. You can decide to use either
pkg
or ports to installpython
. A text editor such asvim
is needed as well to write the server.Note: when logging in as a non-root user, make sure to utilize
doas
orsudo
before proceed on usingpkg
or ports to install any package.
-
Copy the server source code into the FreeBSD guest VM. Preferrably to the home directory of a non-root user.
-
Place the HTML files in the same directory of the server.
-
To establish connection between host machine to the guest VM, in the network settings of the VM, please change Adapter 1 option to Host-Only Adapter. If you don't have any adapter yet, you may create a new adapter in Host Network Manager, and make sure the DHCP Server option is checked. For other options, please keep them in default setting.
-
Run the server with
python
command. -
In the host machine, open a web browser, and type
http://<your-server-ip-address>:<port-number>/<path-to-file>
. For example:http://192.168.###.###:8080/index.html
-
Check out the result and... Voila!