Skip to content

Instantly share code, notes, and snippets.

@phunehehe
Last active August 18, 2020 06:23
Show Gist options
  • Save phunehehe/5097331 to your computer and use it in GitHub Desktop.
Save phunehehe/5097331 to your computer and use it in GitHub Desktop.
Philesight on Ubuntu

Install dependencies

sudo apt-get install libdb4.2-ruby1.8 libcairo-ruby1.8

Install Philesight

git clone https://github.com/phunehehe/philesight.git
cd philesight
sudo ./philesight --db philesight.db --index /

Nginx

Nginx doesn't run CGI on its own, we need a wrapper:

sudo apt-get install fcgiwrap

Run fcgiwrap on port 8888

fcgiwrap -s tcp:127.0.0.1:8888

Add Nginx site /etc/nginx/sites-available/philesight

server {

    server_name philesight.domain.com;
    root        /home/phunehehe/philesight;

    location ~ /.*\.cgi$ {
        gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped
        fastcgi_pass  127.0.0.1:8888;
        fastcgi_index index.cgi;
        fastcgi_param SCRIPT_FILENAME   /home/phunehehe/philesight$fastcgi_script_name;
        fastcgi_param QUERY_STRING      $query_string;
        fastcgi_param REQUEST_METHOD    $request_method;
        fastcgi_param CONTENT_TYPE      $content_type;
        fastcgi_param CONTENT_LENGTH    $content_length;
        fastcgi_param GATEWAY_INTERFACE CGI/1.1;
        fastcgi_param SERVER_SOFTWARE   nginx;
        fastcgi_param SCRIPT_NAME       $fastcgi_script_name;
        fastcgi_param REQUEST_URI       $request_uri;
        fastcgi_param DOCUMENT_URI      $document_uri;
        fastcgi_param DOCUMENT_ROOT     $document_root;
        fastcgi_param SERVER_PROTOCOL   $server_protocol;
        fastcgi_param REMOTE_ADDR       $remote_addr;
        fastcgi_param REMOTE_PORT       $remote_port;
        fastcgi_param SERVER_ADDR       $server_addr;
        fastcgi_param SERVER_PORT       $server_port;
        fastcgi_param SERVER_NAME       $server_name;
    }
}

Enable the site

sudo nxensite philesight
sudo /etc/init.d/nginx restart

Apache

Add site /etc/apache2/sites-available/philesight:

<VirtualHost *:80>

    ServerName philesight.domain.com
    DocumentRoot /home/phunehehe/philesight

    <Directory "/home/phunehehe/philesight">
        Options +ExecCGI
        AddHandler cgi-script .cgi
    </Directory>

</VirtualHost>

Enable it

sudo a2ensite philesight
sudo /etc/init.d/apache2 reload

Done

Enjoy the graph at http://philesight.domain.com/philesight.cgi

@phunehehe
Copy link
Author

Trying the following for ruby 1.9:

sudo gem install cairo
sudo apt-get install libdb-dev
sudo gem install bdb

But it's not working:

/home/phunehehe/philesight/philesight.rb:57:in `rescue in db_open': uninitialized constant Philesight::BDB (NameError)
        from /home/phunehehe/philesight/philesight.rb:54:in `db_open'
        from ./philesight:106:in `<main>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment