How to Install dpaste on Ubuntu Server

Dpaste is a simple open-source pastebin software that enables us to store plain text and code snippets online. In this tutorial, we are going to learn how to install dpaste on Ubuntu Server.

Prerequisites

Before we start, we need to ensure that our server is updated and has the latest software packages. We can do that by running the following command:

sudo apt update && sudo apt upgrade

Install dpaste

  1. First, we need to install Python and pip.

    sudo apt install python3 python3-pip
    
  2. Next, we install dpaste using pip.

    sudo pip3 install dpaste
    

    This command will install dpaste and all its dependencies.

  3. We now need to create a dpaste user for running the dpaste service.

    sudo adduser dpaste
    
  4. We will now create a file /etc/systemd/system/dpaste.service and add the following content.

    [Unit]
    Description=dpaste
    After=network.target
    
    [Service]
    Type=simple
    User=dpaste
    WorkingDirectory=/home/dpaste
    ExecStart=/usr/local/bin/dpaste run
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
  5. Reload the systemd daemon.

    sudo systemctl daemon-reload
    
  6. Start the dpaste service.

    sudo systemctl start dpaste
    
  7. Verify that dpaste is running by issuing the following command.

    sudo systemctl status dpaste
    

    If everything is running correctly, you should see something similar to the following.

    ● dpaste.service - dpaste
       Loaded: loaded (/etc/systemd/system/dpaste.service; enabled; vendor preset: enabled)
       Active: active (running) since Thu 2021-11-11 16:55:01 UTC; 2s ago
     Main PID: 32560 (dpaste)
        Tasks: 1 (limit: 456)
       Memory: 32.0M
       CGroup: /system.slice/dpaste.service
               └─32560 /usr/bin/python3 /usr/local/bin/dpaste run
    
    Nov 11 16:55:01 ubuntu2004 systemd[1]: Started dpaste.
    

Configure dpaste

  1. We need to create a configuration file for dpaste.

    sudo mkdir /etc/dpaste
    
  2. Create a file /etc/dpaste/dpaste.conf with the following contents:

    # DPaste Server Configuration
    
    # The interface and port to bind.
    bind = "0.0.0.0:8000"
    
    # The database URL. By default, dpaste uses an SQLite database.
    database = "sqlite:///dpaste.sqlite3"
    
    # The path to the templates folder.
    templates = "/usr/local/lib/python3.6/dist-packages/dpaste/templates"
    
    # Whether to debug or not.
    debug = True
    
  3. We now need to restart the dpaste service for changes to take effect.

    sudo systemctl restart dpaste
    

    That's it! We have successfully installed and configured dpaste on Ubuntu Server. We can now start using it as a pastebin service.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!