Programming Marathon

Boca Installation

Updated on July 19, 2013

Follow the INSTALL.TXT

  1. Install dependencies

    julio@acer ~> sudo pacman -S php php-pgsql php-mcrypt php-gd postgresql
    
  2. Uncomment the following lines in /etc/php/php.ini

    extension=pdo_pgsql.so
    extension=pgsql.so
    extension=zip.so
    
  3. Edit the PostgreSQL configuration:

    listen_addresses = 'localhost'
    (* = all)
    
  4. Set the encoding of new databases to UTF-8

    This step is unnecessary, but without it, you will have to type ENCODING = 'UTF8' every time you want to create a UTF8 database.

    julio@acer ~> psql
    psql (9.1.2)
    Type "help" for help.
    
    julio=# UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
    UPDATE 1
    julio=# DROP DATABASE template1;
    DROP DATABASE
    julio=# CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
    CREATE DATABASE
    julio=# UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
    UPDATE 1
    
  5. Restart PostgreSQL:

    julio@acer ~> sudo systemctl restart postgresql
    
  6. Download a recent version of Boca: ime.usp.br/~cassio/boca

  7. Unzip the file and move the folder to the server

    [root@acer Downloads]# tar xvfz boca-1.4.2.tgz
    [root@acer Downloads]# mv boca-1.4.2 /srv/http/boca
    
  8. Edit Apache settings:

    julio@acer ~> sudo vim /etc/httpd/conf/httpd.conf
    
    #BOCA
    <Directory /srv/http/boca>
           AllowOverride Options AuthConfig Limit
           Order Allow,Deny
           Allow from all
           AddDefaultCharset utf-8
    </Directory>
    <Directory /srv/http/boca/private>
           AllowOverride None
           Deny from all
    </Directory>
    <Directory /srv/http/boca/doc>
           AllowOverride None
           Deny from all
    </Directory>
    <Directory /srv/http/boca/tools>
           AllowOverride None
           Deny from all
    </Directory>
    
  9. Create the user “boca”, able to create databases:

    julio@acer ~> psql
    julio=# CREATE USER boca WITH PASSWORD 'OUKLsjVs2GLby79' createdb;
    
  10. As root, edit the file /srv/http/boca/private/conf.php

    <?php
    function globalconf() {
        $conf["dbencoding"]="UTF8";
        $conf["dbclientenc"]="UTF8";
        $conf["dblocal"]="false";
        $conf["dbhost"]="localhost";
        $conf["dbport"]="5432";
        $conf["dbname"]="bocadb";
        $conf["dbuser"]="boca";
        $conf["dbpass"]="senha";
        $conf["dbsuperuser"]="senha";
        $conf["dbsuperpass"]="senha";
        $conf["basepass"]="142857";
        $conf["key"]="GG5ALEATORIOjJprR6ex";
        $conf["ip"]='local';
        return $conf;
    }
    ?>
    

    To generate a random key and the boca password, you can use the following command:

    julio@acer ~> echo `tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c25`
    

    Or another random password generator like pwgen, makepasswd, apg, or KeePassX.

  11. As root, run the following command inside the private folder:

    [root@acer private]# php createdb.php
    This will erase all the data in your bocadb database.
    ***** YOU WILL LOSE WHATEVER YOU HAVE THERE!!! *****
    Type YES and press return to continue or anything else will abort it: YES
    
    dropping database
    PHP Warning:  date(): It is not safe to rely on the system's timezone settings. ()
    creating database
    creating tables
    creating initial fake contest
    

Here it gave a Fatal error: Call to undefined function define_syslog_variables() and I simply commented out the corresponding line in globals.php.

  1. Go to http://localhost/boca/src/index.php. The login screen should appear, the username is system and there is no password. Create a password in Options

If it complains that the file conf.php is not readable, run chmod +x private.

NOTE: The website also has a script available that performs automatic installation (downloads updates, creates users, changes the grub, and autoconfigures Boca) but it has a lot of specific things for Ubuntu. If you are using this distribution, download the script HERE.

Installing on a server without root password

Well, Boca ran very well on my computer and is even accessible from the internet, but using my notebook as a server with the connection speed here at home is not very stable. Since I am paying for this server, I decided to install Boca right here.

The process is identical up to step 10, but step 11 needs to be executed as root and I do not have the root password, as the server is shared. The solution is to copy the database that the script created on my computer to the server:

  1. julio@acer ~> pg_dump -C -Fp -f dump.sql -U postgres bocadb

  2. julio@acer ~> scp dump.sql juliobor@juliob.org:~

  3. julio@acer ~> ssh juliobor@juliob.org

  4. juliobor@box780 ~ $ psql -U juliobor_boca -f dump.sql


Julio Batista Silva
Julio Batista Silva
Data Engineer

I’m a computer engineer passionate about science, technology, photography, and languages. Currently working as a Data Engineer in Germany.

comments powered by Disqus