Linux serverlinux web serverNETWORK ADMINISTRATIONS

Create An Easy to Use, Locally Hosted Bash Script Repository

#Linux #Bash #Self-host

Full steps can be found at https://i12bretro.github.io/tutorials/0477.html

In this example I’ll be installing Apache2 on a Debian VM, but the server can be hosted on any OS or web server capable of serving .sh files.

——————————————————————–
Installing a Web Server
——————————————————————–
01. Log into the Linux device
02. Run the following commands in a terminal window:
# update software repositories
sudo apt update
# install available software updates
sudo apt upgrade -y
# install apache2 webserver and curl
sudo apt install apache2 curl -y
# create a subfolder in the webroot to store .sh files
sudo mkdir /var/www/html/bash -p

——————————————————————–
Creating a Sample Bash Script
——————————————————————–
01. Continue with the following command to create a sample bash script
sudo nano /var/www/html/bash/whoami.sh
02. Paste the following script into whoami.sh
#!/bin/bash
echo “hello, today is $(date ‘+%A’). You are running me as $(whoami).”
03. Press CTRL+O, Enter, CTRL+X to write the changes to whoami.sh

——————————————————————–
Executing the Sample Bash Script
——————————————————————–
01. Continue with the following command to execute the sample script
curl http://DNSorIP/bash/whoami.sh | bash

source

by i12bretro

linux web server

Leave a Reply

Your email address will not be published. Required fields are marked *