Gunakan Privatebin, pastebin open source, sebagai tempat mencadangkan teks. Mari kita bahas cara install privatebin di Linux.

Privatebin, Pastebin Open Source

Pernahkah kamu berhasrat menyediakan layanan bak Pastebin di peladen (server) sendiri? Realisasikan ide dengan PrivateBin!

Privatebin adalah pastebin open source dan minimalis untuk menyimpan teks dalam enkripsi 256 bits AES. Pihak pengembang mengatakan bahwa pemilik server pun tidak punya informasi tentang data yang tersimpan.

Cara Install Privatebin di Linux

Kita membutuhkan php, mariadb, git, dan nginx untuk memasang PrivateBin. Sebelum memulai, pastikan kamu sudah menyiapkan paket-paketnya.

$ sudo apt install -y mariadb-server mariadb-client git nginx php php-xml php-mbstring php-mysql php-json php-pdo 

Kita unduh berkas PrivateBin melalui teknik git clone di direktori /var/www.

# cd /var/www/
# git clone https://github.com/PrivateBin/PrivateBin.git

Beri akses Nginx di direktori Privatebin.

# chown -R www-data:www-data PrivateBin/

Kita buat konfigurasi Nginx untuk Privatebin agar dapat diakses.

# vim /etc/nginx/nginx.conf

Jangan lupa ubah value sesuai konfigurasi kamu.

server {
    root /var/www/privatebin/PrivateBin;
    index  index.php index.html index.htm;
    server_name txt.radhitya.org;
    client_max_body_size 500M;	
autoindex off;
#Hide the nginx version.
server_tokens off;
#Hide the PHP version.
fastcgi_hide_header X-Powered-By;
proxy_hide_header X-Powered-By;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }
    location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;
    }
  }

Kali ini kita akan menyiapkan pemasangan MariaDB. Silahkan lakukan setup untuk pengguna baru.

# mysql_secure_installation

Jika sudah setup, masuk ke mysql dengan akun kamu.

# mysql -u root -p

Kita buat database baru bernama privatebin.

MariaDB [(none)]> CREATE DATABASE privatebin;

Bikin pengguna dan kata sandi melalui perintah di bawah.

MariaDB [(none)]> CREATE USER 'privatebin'@'localhost' IDENTIFIED BY 'newpassword';

Beri akses kekuasaan pengguna terhadap database privatebin.

MariaDB [(none)]> GRANT ALL PRIVILEGES ON privatebin.* TO 'privatebin'@'localhost';
MariaDB [(none)]> exit;

Ubah direktori ke Privatebin.

# cd /var/www/PrivateBin/cfg/

Salin berkas contoh conf.sample.php dan tempel sebagai conf.php.

# cp conf.sample.php conf.php

Kita ubah konfigurasi agar data tersimpan pada database.

# vim conf.php
; [model]
; name of data model class to load and directory for storage
; the default model "Filesystem" stores everything in the filesystem
; class = Filesystem
; [model_options]
; dir = PATH "data"

[model]
class = Database
[model_options]
dsn = "mysql:host=localhost;dbname=privatebin;charset=UTF8"
tbl = "privatebin_" ; table prefix
usr = "privatebin"
pwd = "newpassword"
opt[12] = true ; PDO::ATTR_PERSISTENT

Terakhir, reset nginx agar perubahan dapat dimuat.

# service nginx reload