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:
Log in to MySQL as the root user by running the following command:
sudo mysql -u root -pEnter the MySQL root password when prompted.
Create a new database for PrivateBin by running the following command:
CREATE DATABASE privatebin;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
passwordwith a strong password of your choice.Exit MySQL by running the following command:
exit
Step 5: Download and install PrivateBin
Now we're ready to install PrivateBin. Follow these steps:
Download the latest version of PrivateBin from the official website:
sudo wget https://github.com/PrivateBin/PrivateBin/archive/master.zip -O privatebin.zipUnzip the downloaded file using the following command:
sudo unzip privatebin.zip -d /var/www/html/Rename the extracted directory to privatebin:
sudo mv /var/www/html/PrivateBin-master /var/www/html/privatebinChange 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:
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.phpOpen the configuration file for editing:
sudo nano /var/www/html/privatebin/config/config.phpLook 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
passwordwith the password you specified earlier.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:
Install
certbotto obtain a free SSL certificate from Let's Encrypt:sudo apt install certbot python3-certbot-apacheObtain a certificate for your server's domain name by running the following command:
sudo certbot --apacheFollow the prompts to obtain and install the certificate.
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.