Programmiermarathon

Jan. 4, 2012·
Julio Batista Silva
Julio Batista Silva
· 3 Min Lesezeit

Installation von BOCA

Aktualisiert am 19. Juli 2013

Folge der Anleitung INSTALL.TXT

  1. Abhängigkeiten installieren:

    julio@acer ~> sudo pacman -S php php-pgsql php-mcrypt php-gd postgresql
    
  2. Die folgenden Zeilen in /etc/php/php.ini auskommentieren:

    extension=pdo_pgsql.so
    extension=pgsql.so
    extension=zip.so
    
  3. PostgreSQL konfigurieren:

    listen_addresses = 'localhost'
    (* = all)
    
  4. Standard‑Kodierung neuer Datenbanken auf UTF‑8 setzen

    Dieser Schritt ist optional, sonst musst du bei jeder DB‑Erstellung „ENCODING = ‘UTF8’“ angeben.

    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. PostgreSQL neu starten:

    julio@acer ~> sudo systemctl restart postgresql
    
  6. Eine aktuelle BOCA‑Version herunterladen: ime.usp.br/~cassio/boca

  7. Archiv entpacken und Ordner auf den Server verschieben:

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

    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. Benutzer „boca“ mit Recht zum Erstellen von Datenbanken anlegen:

    julio@acer ~> psql
    julio=# CREATE USER boca WITH PASSWORD 'OUKLsjVs2GLby79' createdb;
    
  10. Als root die Datei /srv/http/boca/private/conf.php bearbeiten:

    <?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;
    }
    ?>
    

    Um einen zufälligen Schlüssel und das BOCA‑Passwort zu erzeugen, kannst du Folgendes nutzen:

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

    Oder Generatoren wie pwgen, makepasswd, apg oder KeePassX.

  11. Als root im Ordner private ausführen:

    [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
    

Hier trat ein „Fatal error: Call to undefined function define_syslog_variables()“ auf – ich habe die entsprechende Zeile in globals.php einfach auskommentiert.

  1. Rufe http://localhost/boca/src/index.php auf. Es sollte der Login erscheinen, der Benutzer ist system ohne Passwort. Lege eines unter Options fest.

Wenn die Datei conf.php als nicht lesbar bemängelt wird, führe chmod +x private aus.

Hinweis: Auf der Website gibt es auch ein Skript zur automatischen Installation (lädt Updates, erstellt Benutzer, ändert den Grub und konfiguriert BOCA), ist aber sehr Ubuntu‑spezifisch. Wenn du Ubuntu nutzt, lade es HIER.

Installation auf Server ohne Root‑Passwort

BOCA lief lokal gut und war sogar aus dem Internet erreichbar, aber meinen Notebook‑Upload als Server zu nutzen ist nichts Stabiles. Also Installation auf dem Hosting.

Der Prozess ist identisch bis Schritt 10, aber Schritt 11 erfordert Root – das Passwort habe ich auf dem Shared‑Server nicht. Lösung: Die vom Skript lokal erstellte Datenbank auf den Server kopieren:

  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
Autoren
Senior Cloud-Entwickler
comments powered by Disqus