How I converted my old laptop into a personal server

Search for a command to run...

No comments yet. Be the first to comment.
Connecting Alexa to a Local LLM Running on Raspberry Pi

Introduction Have you ever used: "It works on my machine,". Now, with containerization and cloud computing technologies like Docker and Amazon EC2, those days are gone. Docker, a leading containerization platform, provides a convenient way to package...

Project: Migrate EHR to Laravel - User & Roles Module Introduction I am excited to present my final work submission report for the Google Summer of Code (GSoC) 2023 project: "Migrating LibreHealth EHR to Laravel: Roles and Users Module." Over the pas...

Introduction: Welcome back to the eleventh week of my exciting journey in the Google Summer of Code program. In this blog post, I'm thrilled to share the progress made during this crucial week, including the completion of requested reviews and change...

Introduction: Welcome back to the tenth week of my exhilarating journey in the Google Summer of Code program. In this blog post, I'm excited to share updates on the accomplishments from the past week, including the successful implementation of the Da...

I had an old laptop with me which was of no use. But I decided to use its resources so I set up this laptop as a personal LAN server first and then made it publicly accessible to others. So do you have an old laptop or PC? You can follow up with me to set up your own server. Let's get started.
We need an operating system for the system. And there is no other option better than the best and most popular Linux distro ie Ubuntu
It is better to use the Ubuntu Server which is very lightweight and best for servers. But setting it up is a bit complex so we can also go with the desktop version.
Download Ubuntu LTS and set up a USB stick with Rufus in the window to make it bootable. Boot the machine with the USB and follow the basic setup to install ubuntu.
You can follow this youtube video: https://www.youtube.com/watch?v=cHF1ByFKtZo&t=371s
SSH stands for Secure Shell or Secure Socket Shell, which is a network protocol that gives users, particularly system administrators, a secure way to access a computer over a network. So, we will set up ssh into our system so that it can be accessed from other devices to operate. For that the first thing we need is to set up a static IP for our Linux machine and the by using OpenSSH-server we will enable ssh.
sudo apt update
ip address
It is suggested to use Ethernet over Wifi for the server machine for faster speed. Wifi works well but it will slow down the process.
Go to your wired setting and then click on the setting icon in place of the connected network. Move to IP4 and select manual.
Provide the manual IP which should be identical to your LAN IP just change the last bits. Similarly provide the Netmask, gateway, and DNS.

Reconnect the network and then check whether your IP got changed or not.
After this, we need to set up shh. For this, we will use openssh-server Type:
sudo apt install openssh-server
sudo systemctl status ssh
sudo ufw allow ssh
username and IP address. ssh captcha@192.168.1.116
yes and then type the password of the user. And Walla!!.You need to be connected to the same local network ie Wifi to ssh into the machine. It can be publicly accessible after following step 5.
The best way you can use this server is to backup your files into it or use it to share files within your devices connected over the LAN ie Wifi. We will see how you can connect your both window pc and mobile phone for file sharing.
sudo apt install samba
mkdir captcha-server
Go to samba config.
sudo nano /etc/samba/smb.conf
Add the following code: Replace your path, username, and directory name
[captcha-server]
comment = Captcha Shared Server
path = /home/captcha/captcha-server
read-only = no
browsable = yes
valid users = captcha
available = yes
guest ok = no
writable = yes
sudo service smbd restart
sudo ufw allow samba
sudo smbpasswd -a captcha
Note: For connecting to the server you must be in the same network ie connected to the same wi-fi
Go to my pc and select an add network location.
Add the network address. Replace your IP and directory name
\\192.168.1.116\captcha-server
Add username and password and then done.
We are all set to access and transfer files from our window machine to the Linux server and vice versa
Go to file manager
Look for the remote option. Click LAN
Similarly, add address, user, and password and connect
Walla!! We have connected to the server.
Now you can back up your files on your old laptop.
You can also use your server to host both static and dynamic web pages. We will be using NGINX for that.
NGINX is open-source software for web serving, reverse proxying, caching, load balancing, media streaming, and more.
sudo apt install nginx
cd /var/www
mkdir test
cd test
nano index.hmml
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
</body>
</html>
cd /etc/nginx/sites-enabled
nano first-webpage
directory name here test server {
listen 8080 default_server;
listen [::]:8080 default_server;
root /var/www/test;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
sudo service nginx restart
Till now whatever we have done is limited to our local network ie over the same wifi. But what if we want to share our server with our friends? For that, we need to implement port forwarding which will forward the requests made from the outside world to our server computer. There are many complex solutions but for me, the best and easy solution is to use Ngrok.
wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz
you can go to offical website for more download options
tar -xvzf /path/to/ngrok-v3-stable-linux-amd64.tgz
./ngrok authtoken "Your auth token"
ngrok http 8080
here 8080 is the port where we have set up our Nginx server
You will get the public link. Open the link in the browser to view the Nginx webpage.
If you press CTRL+C . It will close the output log as well as the ngrok service.
There are many ways to run the ngrok in the background process. But after testing them all I found the best one;
sudo ngrok http 8080 --log=stdout > ngrok.log &
nano ngrok.log
You can also access your server through ssh
sudo ngrok tcp 22 --log=stdout > ngrok.log &
Open the log file and you will find the server address
Just ssh into it
# Assuming your URL was tcp://0.tcp.jp.ngrok.io:11111
ssh <YOUR_USERNAME>@0.tcp.jp.ngrok.io -p 11111
We made it this far 🎉. For us, the sky is the limit. You can host your Minecraft server and Video streaming server on your machine. Hope you have followed the steps correctly and got your desired results.
This is my blog post and hopes you enjoyed it. In return I just want you to like and share it with other techies. You can also comment down your queries and suggestions which are most welcome.