---
title: "Step by Step Guide to Setting Up Hastebin on Your Ubuntu Server - CloudBlast"
description: "Step by Step Guide to Setting Up Hastebin on Your Ubuntu Server"
url: "https://cloudblast.io/ar/article/Step-by-Step-Guide-to-Setting-Up-Hastebin-on-Your-Ubuntu-Server"
language: "ar-SA"
---

المدونة

# Step by Step Guide to Setting Up Hastebin on Your Ubuntu Server

رصيد مجاني 5€ عند التسجيل

سجّل في CloudBlast واحصل على رصيد سحابي مجاني بقيمة 5€ لنشر خوادم VPS الخاصة بك

[احصل على 5€ مجانًا](https://console.cloudblast.io/auth/login?ref=2)

-   [رجوع](https://cloudblast.io/ar)
-   [جميع المقالات](https://cloudblast.io/ar/blog)

2025-04-15

### Step by Step Guide to Setting Up Hastebin on Your Ubuntu Server

tutorials

Looking to share code snippets or text quickly and securely? Hastebin is a fantastic open-source tool that lets you host your own pastebin service. Itâ€™s lightweight, user-friendly, and perfect for developers or anyone needing to share text fast. In this guide, weâ€™ll walk you through installing Hastebin on the latest Ubuntu Server, tailored for Cloudblast users who want a seamless setup. Letâ€™s dive in!

### What Youâ€™ll Need Before Starting

Before we get going, make sure you have:

-   An Ubuntu Server (preferably the latest version) up and running.
-   Root or sudo access to execute commands.
-   A stable internet connection for downloading packages.
-   Basic familiarity with the terminal (donâ€™t worry, weâ€™ll keep it simple!).

Got everything? Awesome, letâ€™s set up Hastebin!

### Step 1: Update Your Ubuntu Server

First things first, letâ€™s ensure your server is fresh and ready. Open your terminal and connect to your server via SSH. Then, run these commands to update the system:

```
sudo apt update
sudo apt upgrade -y
```

This grabs the latest package lists and installs any available updates, keeping your server secure and stable.

### Step 2: Install Node.js and npm

Hastebin runs on Node.js, so we need to install it along with npm (Nodeâ€™s package manager). Ubuntuâ€™s repositories make this super easy. Type the following:

```
sudo apt install nodejs npm -y
```

Once done, verify the installation to confirm everythingâ€™s in place:

```
node --version
npm --version
```

You should see version numbers pop up. If you do, youâ€™re good to go!

### Step 3: Download and Install Hastebin

Now, letâ€™s grab Hastebin. Weâ€™ll use npm to install it globally, which simplifies things. Run this command:

```
sudo npm install -g haste-server
```

This pulls down Hastebin and its dependencies. It might take a minute, so grab a coffee if youâ€™d like!

### Step 4: Set Up the Hastebin Directory

Hastebin needs a place to live on your server. Letâ€™s create a directory for it and move in:

```
sudo mkdir /opt/hastebin
cd /opt/hastebin
```

Here, weâ€™ll configure Hastebin to run smoothly.

### Step 5: Configure Hastebin

Hastebin uses a configuration file to customize settings like the port it runs on. Letâ€™s create one. Use a text editor like nano:

```
sudo nano config.json
```

Paste the following basic setup into the file:

```
{
    "host": "0.0.0.0",
    "port": 80,
    "keyLength": 10,
    "maxLength": 400000,
    "staticMaxAge": 86400
}
```

Hereâ€™s what these settings do:

-   **host**: Binds Hastebin to all network interfaces.
-   **port**: Sets Hastebin to run on port 80 (standard HTTP). You can change this if needed.
-   **keyLength**: Defines the length of paste IDs.
-   **maxLength**: Limits paste size (400,000 characters is plenty!).
-   **staticMaxAge**: Sets caching for static files (in seconds).

Save the file by pressing **Ctrl+O**, then **Enter**, and exit with **Ctrl+X**.

### Step 6: Start Hastebin

Time to fire it up! From the `/opt/hastebin` directory, start Hastebin with:

```
sudo hastebin
```

If allâ€™s well, Hastebin will start running. Open a web browser and navigate to your serverâ€™s IP address (e.g., `http://your-server-ip`). You should see Hastebinâ€™s clean interface, ready for you to paste and share.

### Step 7: Make Hastebin Run Automatically

Manually starting Hastebin every time isnâ€™t ideal. Letâ€™s use PM2, a handy process manager, to keep it running in the background and restart it on server reboots.

Install PM2 globally:

```
sudo npm install -g pm2
```

Now, start Hastebin with PM2:

```
pm2 start /usr/bin/hastebin --name hastebin
```

Save the PM2 configuration to ensure it runs on boot:

```
pm2 save
pm2 startup
```

Follow any on-screen instructions to complete the setup. Now, Hastebin will stay online without you lifting a finger!

### Step 8: Secure Your Setup (Optional but Recommended)

Running Hastebin on port 80 is great for testing, but for production, consider these steps:

-   **Add a Reverse Proxy**: Use Nginx or Apache to handle traffic and enable HTTPS with a free SSL certificate from Letâ€™s Encrypt.
-   **Firewall**: Restrict access with UFW. Allow only necessary ports (e.g., 80, 443, and 22 for SSH):

```
sudo ufw allow 80
sudo ufw allow 443
sudo ufw allow 22
sudo ufw enable
```

-   **Change the Port**: If you donâ€™t want to use port 80, update `config.json` and adjust your firewall rules.

These steps keep your server safe and your Hastebin instance secure.

### Wrapping Up

Congrats! Youâ€™ve just set up Hastebin on your Ubuntu Server with Cloudblast. Now you can share code, notes, or any text with ease. Whether youâ€™re collaborating with a team or just need a quick way to store snippets, Hastebinâ€™s got you covered.

Want to take it further? Explore Hastebinâ€™s GitHub repo for advanced tweaks or reach out to the Cloudblast community for tips on optimizing your server. Happy pasting!

_Need more server tutorials? Check out our other Cloudblast guides for hosting solutions, analytics, and more!_

مشاركة

## متابعة القراءة

[2026-07-25 How to Install and Set Up Mailcow on Ubuntu and Debian VPS tutorials](https://cloudblast.io/article/how-to-install-and-setup-mailcow-on-ubuntu-and-debian-vps)

[2026-07-25 How to Install Chatwoot on the Latest Ubuntu and Debian Server tutorials](https://cloudblast.io/article/how-to-install-chatwoot-on-ubuntu-and-debian-server)

[2026-07-25 How to Install Mattermost on the Latest Ubuntu and Debian Server tutorials](https://cloudblast.io/article/how-to-install-mattermost-on-ubuntu-and-debian-server)

[2026-07-25 How to Install RustDesk on the Latest Ubuntu and Debian Server tutorials](https://cloudblast.io/article/how-to-install-rustdesk-on-ubuntu-and-debian-server)
