How to make own VPS in laptop or desktop

If you're looking to set up your own VPS server on a laptop or Raspberry Pi, here's a step-by-step guide to install all the tools you need to host unlimited websites using Webmin, DuckDNS, Apache, and Cloudflare for free SSL. This guide is tailored for an Ubuntu server running on VirtualBox, but the steps apply to most Ubuntu installations.


Step 1: Setting Up the Ubuntu Virtual Machine

1. Install VirtualBox and Create a VM

  • Download and install Oracle VirtualBox.
  • Create a new virtual machine:
    • Select Ubuntu (64-bit) as the operating system.
    • Allocate at least 2GB RAM and 20GB disk space.
    • Attach an Ubuntu ISO file and install Ubuntu.

2. Enable Networking

  • Set the VirtualBox network adapter to Bridged Mode so the VM can access your local network and internet.
  • Boot into the Ubuntu VM and update the system:
    bash

    sudo apt update && sudo apt upgrade -y

Step 2: Install Webmin

Webmin is a powerful web-based control panel for managing servers.

1. Install Dependencies

Run the following commands:

bash

sudo apt install wget software-properties-common apt-transport-https -y

2. Add the Webmin Repository

bash

wget -qO - http://www.webmin.com/jcameron-key.asc | sudo apt-key add
sudo add-apt-repository "deb http://download.webmin.com/download/repository sarge contrib"

3. Install Webmin


sudo apt update sudo apt install webmin -y

Tips : when you will run command to install webmin may be throw error in ubunto somting like "dpkg was interrupted" so run this command to fix

sudo dpkg --configure -a

4. Allow Webmin Through the Firewall

If ufw (Uncomplicated Firewall) is enabled:



sudo ufw allow 10000 sudo ufw reload

5. Access Webmin

Open a browser on your host machine and go to:

to ckeck you vm ip run 

ip addr

if still ip address not showing run this command
sudo ip link set enp0s3 up

then run again ip addr command 

https://<VM-IP>:10000

Log in with your Ubuntu username and password.


Step 3: Set Up DuckDNS for Dynamic DNS

DuckDNS helps you manage a domain name even if your ISP assigns a dynamic IP.

1. Install DuckDNS

Run these commands:

bash

mkdir duckdns cd duckdns wget https://www.duckdns.org/install.duckdns.sh chmod +x install.duckdns.sh

2. Configure DuckDNS

Edit the install.duckdns.sh script:

bash

nano install.duckdns.sh

Add your DuckDNS token and desired subdomain:

bash

echo "your-subdomain" > /path/to/duckdns-token

Save the file and set up a cron job to run the script every 5 minutes:

bash

(crontab -l ; echo "*/5 * * * * /path/to/install.duckdns.sh") | crontab -

Step 4: Install Apache Web Server

Apache will serve your websites.

1. Install Apache

bash

sudo apt install apache2 -y

2. Enable Apache

Start and enable Apache:

bash

sudo systemctl start apache2 sudo systemctl enable apache2

3. Allow HTTP and HTTPS Through the Firewall

bash

sudo ufw allow 80 sudo ufw allow 443 sudo ufw reload

Step 5: Configure Cloudflare for Free SSL

Cloudflare provides free SSL certificates and helps with DNS management.

1. Point DuckDNS to Cloudflare

  • Log in to your Cloudflare account.
  • Add your domain or subdomain.
  • Configure the DNS settings to point to your DuckDNS subdomain.

2. Enable SSL

  • In Cloudflare’s dashboard, go to the SSL/TLS tab.
  • Select Full (Strict) mode.

Step 6: Test Your Setup

  1. Access the Apache Server

    • Open a browser and visit your DuckDNS domain:
      arduino

      http://your-subdomain.duckdns.org
  2. Test HTTPS

    • Ensure HTTPS works by visiting:
      arduino

      https://your-subdomain.duckdns.org

Optional: Monitor and Manage with Webmin

Use Webmin to:

  • Add virtual hosts for multiple websites.
  • Monitor server performance.
  • Configure DNS, firewalls, and more.

No comments:

Post a Comment

Pages