From Alpine Linux

A quick'n dirty doc about how to install a private pastebin service.

There are a lot of pastebin services ( We're going to use the oldest pastebin service, without DB support but only file.


  • An up-and-running Web server (here are quoted apache, but is also possible to add nginx and lighttpd configuration) with modules:
  • PHP
  • vhosts
  • mod_rewrite (for Apache and lighttpd, or NginxHttpRewriteModule for nginx)

Download Pastebin setup file


Web Server Configuration to host pastebin

Apache Unzip the downloaded file in the web server vhosts dir:

tar -zxvf pastebin.tar.gz -C /var/www/vhosts

Rename vhosts dir:

mv /var/www/vhosts/pastebin-0.60 /var/www/vhosts/pastebin

  • Edit /etc/apache/httpd.conf and add the following:
       <VirtualHost *:80>
               DocumentRoot /var/www/vhosts/pastebin/public_html
               ErrorLog /var/log/apache2/pastebin-error.log
               CustomLog /var/log/apache2/pastebin-access.log common
               php_value include_path .:/var/www/vhosts/pastebin/lib
               php_value register_globals off
               DirectoryIndex pastebin.php
               RewriteEngine on
               RewriteLog /var/log/apache2/pastebin-rewrite.log
               RewriteRule /([a-z0-9]+)$ /pastebin.php?show=$1 [L]


  • Edit lighttpd.conf:
$HTTP["host"] =~ "(^|\.)paste.bin\.com$" {
   server.document-root = "/var/www/vhosts/pastebin/public_html"
   accesslog.filename = "/var/log/lighttpd/pastebin/access.log"
    fastcgi.server = (
       ".php" => (
           "localhost" => (
               "bin-path" => "/usr/bin/php-cgi",
               "socket" => "/tmp/php-pastebin.socket",
               "min-procs" => 1,
                "max-procs" => 2,
                "bin-copy-environment" => (
                    "PATH", "SHELL", "USER"
    compress.cache-dir = "/var/www/cache/pastebin/"
    url.rewrite-once = (
        "^/(pastebin.css)" => "$0",
        "^/(pastebin.js)" => "$0",
        "^/diff/(.*)" => "/pastebin.php?diff=$1",
        "^/(.*)" => "/pastebin.php?show=$1"


  • Edit nginx.conf (this is the significative part).
rewrite ^/([a-z0-9]+)$/pastebin.php?show=$1 last;
Warning: Nginx and Lighttpd configuration was not tested. These directive give you an idea on how is possible to implement pastebin on those web servers.

Configure pastebin

The configuration file is outside the directory "public_html", but is in "/lib/config" dir.

Copy default.conf.php into file that match your fqdn where pastebin service is hosted (e.g. with .conf.php extension.

In this case, will be:

  • Edit and modify the following part:

The others directive are not mandatory, but should be modified according with your needs.

The first directive mean that the backend must be a file instead of mysql (that is by default).

The second specify which part of the filename is the domain name.

In this case the number is 2: mydomain and com.

Now, you have to create the directory that will contain the posts file.

According with db.file.class.php the directory must be $_SERVER['DOCUMENT_ROOT'].'/../posts/ and must be writable by the user which runs webserver daemon.

mkdir -p /var/www/vhosts/pastebin/posts chown apache:apache /var/www/vhosts/pastebin/posts

Now, restart the web server. Pastebin service should be reachable on