Step #1: Set the Deno installation directory
Step #2: Run Deno's official installation script
sudo curl -fsSL https://deno.land/x/install/install.sh | sh
Step #3: Verify Deno installation
Installing Deno was super easy. At this point, running a Deno script that serves content would only serve the data to localhost. We will use the webserver Nginx to make the content publicly available.
At this point, loading your server/host endpoint will return an Nginx error. nginx is expecting to forward the request to port 8000, but there is currently no process listening on port 8000
Step #7: Start Deno server
In this example, we will run a straightforward file server. The script will serve files from the current directory. Nginx is configured to forward connections to port 8000, so we need to tell the script to run on port 8000 explicitly.
deno run --allow-read --allow-net https://deno.land/std/http/file_server.ts --port=8000
Your Deno server is now publicly available!
This executes from my local workspace, which contains a file test-file.txt.
Note: Deno is secure by default, meaning the environment is sandboxed. The command to run the example script requires the –allow-net and –allow-read argument flags to serve the content via the network.