Installing PrivateBin on Ubuntu Server

PrivateBin is a free and open-source online tool for sharing sensitive information securely. In this tutorial, we will guide you through the process of installing PrivateBin on Ubuntu Server.

Step 1: Update and upgrade the system

Before installing any new software, it's always recommended to update and upgrade the system to its latest version. To do so, run the following command:

sudo apt update && sudo apt upgrade -y

This command will update the package lists and upgrade any packages that need to be updated.

Step 2: Install Apache and PHP

PrivateBin requires a web server and PHP to work properly. Use the following command to install these dependencies:

sudo apt install apache2 php libapache2-mod-php php-mbstring php-gd php-xml php-json

This command will install Apache web server, the PHP language, and some necessary PHP extensions.

Step 3: Install MySQL

PrivateBin stores its data in a database. We will use MySQL as our database management system. To install MySQL, run the following command:

sudo apt install mysql-server mysql-client

During the installation process, you'll be prompted to set the MySQL root password. Choose a strong password and remember it; you'll need it later.

Step 4: Set up a MySQL database for PrivateBin

Next, we need to create a new MySQL database and a user with permissions to access that database. To do so, follow these steps:

  1. Log in to MySQL as the root user by running the following command:

    sudo mysql -u root -p
    
  2. Enter the MySQL root password when prompted.

  3. Create a new database for PrivateBin by running the following command:

    CREATE DATABASE privatebin;
    
  4. Create a new user and grant them permissions to access the database by running the following command:

    GRANT ALL PRIVILEGES ON privatebin.* TO 'privatebin'@'localhost' IDENTIFIED BY 'password';
    

    Replace password with a strong password of your choice.

  5. Exit MySQL by running the following command:

    exit
    

Step 5: Download and install PrivateBin

Now we're ready to install PrivateBin. Follow these steps:

  1. Download the latest version of PrivateBin from the official website:

    sudo wget https://github.com/PrivateBin/PrivateBin/archive/master.zip -O privatebin.zip
    
  2. Unzip the downloaded file using the following command:

    sudo unzip privatebin.zip -d /var/www/html/
    
  3. Rename the extracted directory to privatebin:

    sudo mv /var/www/html/PrivateBin-master /var/www/html/privatebin
    
  4. Change the ownership of the privatebin directory to the Apache web server user (www-data):

    sudo chown -R www-data:www-data /var/www/html/privatebin
    

Step 6: Configure PrivateBin

Before we can use PrivateBin, we need to configure it. Follow these steps:

  1. Copy the sample configuration file to the PrivateBin directory:

    sudo cp /var/www/html/privatebin/config/cfg.sample.php /var/www/html/privatebin/config/config.php
    
  2. Open the configuration file for editing:

    sudo nano /var/www/html/privatebin/config/config.php
    
  3. Look for the following lines and modify them as shown:

    $config['baseurl'] = ''; // Change to the URL where you'll access PrivateBin
    $config['database'] = array(
        'adapter'   => 'mysql',
        'dsn'       => 'mysql:dbname=privatebin;host=localhost;charset=utf8mb4', // The name of the database we created earlier
        'username'  => 'privatebin', // The username we created earlier
        'password'  => 'password', // The password we specified earlier
        'table_prefix' => '',
    );
    

    Replace password with the password you specified earlier.

  4. Save and exit the configuration file (Ctrl+O, Ctrl+X).

Step 7: Secure PrivateBin

To secure PrivateBin, we recommend configuring it to use HTTPS. Follow these steps:

  1. Install certbot to obtain a free SSL certificate from Let's Encrypt:

    sudo apt install certbot python3-certbot-apache
    
  2. Obtain a certificate for your server's domain name by running the following command:

    sudo certbot --apache
    

    Follow the prompts to obtain and install the certificate.

  3. Restart Apache to apply the certificate:

    sudo systemctl restart apache2
    

Step 8: Access PrivateBin

Congratulations, you've successfully installed PrivateBin on your Ubuntu Server! You can now access it by visiting the URL you specified in the configuration file.

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!