Mittwoch, 1. Oktober 2008

twitter-Klon identi.ca mit laconi.ca-Code

Es ist eine Baustelle. Und dies ist mehr ein handschriftliches Protokoll, denn eine Anleitung... Die offizielle Installationshilfe gibt's hier. Aber so hab ich die Grundkonfiguration von laconi.ca (basis von identi.ca) wenigstens mal hochbekommen beim Hoster slicehost: 1. Mit dem Slicemanager bei slicehost ein leeres Ubuntu 8.04.1 LTS (hardy) slice erstellen. Einloggen! Dann (letztmals aktualisiert am 18.10.08):
# mein Lieblingseditor:
aptitude install joe

# Instructions um aktuellste Versionen von php5 etc. bei slicehost zu installieren, weil's sont wegen eines php-Bugs nicht geht. Siehe hier:
# Using Dotdeb is very simple:
# 1. Add these two lines to your /etc/apt/sources.list file (choosing a mirror near you) :
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
# 2. Run apt-get update
# 3. You should now be able to use the Dotdeb packages with apt-get (or dselect, or aptitude as well…)

joe /etc/apt/sources.list

aptitude update
aptitude upgrade

# Zeitzone richtig setzen
cp /usr/share/zoneinfo/Europe/Zurich /etc/localtime

# mal rebooten zur sicherheit
reboot

# Der neuen, virtuellen Kiste Deutsch beibringen:
aptitude install language-pack-de language-pack-de-base (fakultativ: language-support-de)

ausgewählt: deutsch (New German 8bit)

# Achtung: Wenn Du die Uebersetzungsdatei /var/www/locale/de_DE/LC_MESSAGES/laconica.po editierst (auf dem Mac z.B. mit Poedit), dann musst Du sie danach in laconica.mo kompilieren. Dazu gettext installieren (aptitude install gettext) und dann "msgfmt -f -o laconica.mo laconica.po".
aptitude install gettext

# nachgeahmt von http://de.gentoo-wiki.com/Deutsche_Lokalisierung
# /etc/einvironment ergänzen um:
LANG="de_DE.UTF-8"
LC_ALL="de_DE.UTF-8"
GDM_LANG="de_DE.UTF-8"

# Den richtigen Zeichensatz einstellen:
# "Latin1 und Latin5 - westeuropäische und türkische Sprachen" auswählen.

sudo dpkg-reconfigure console-setup

reboot

# postfix installieren

aptitude install postfix

# lokal unbekannte mailadressen verarbeiten. So geht das:

in /etc/postfix/main.cf
local_recipient_maps = (leer!)
fallback_transport = laconicatrans

in /etc/postfix/master.cf
laconicatrans unix - n n - 1 pipe flags=X user=www-data argv=/var/www/scripts/maildaemon.php

# das hat allerdings zur Folge, dass alle mails
# angenommen werden und an die unbekannten
# fehlermeldungen abgeschickt werden.
# ACHTUNG: Posting-Mails müssen in UTF-8 kodiert sein.

# Jetzt MySQL installieren:
aptitude install mysql-server mysql-client libmysqlclient15-dev
#mysql root passwort setzen (daspasswort)
mysqladmin password daspasswort

# installation von apache und php:
aptitude install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5-cgi php5-cli php-pear php5-gd php5-mysql libgmp3c2 php5-curl php5-mailparse php5-dev php5-memcache

# rewrite- und include-Modul aktivieren:

a2enmod rewrite
a2enmod include
sudo /etc/init.d/apache2 reload

# einige Zusatzmodule installieren, die offenbar notwendig sind
# zusätzlich zu denen in /var/www/extlib
# diese landen in /usr/share/php
sudo pear install Mail_mimeDecode
sudo pear install Net_SMTP
#
# in /var/www/extlib habe ich
# PEAR.php
# umbenannt in
# PEAR.php.orig
# weil mal eine Fehlermeldung kam, es sei etwas doppelt definiert
# PEAR.php ist auch in /usr/share/php Seither keine errors

# den laconi.ca Code aus dem Repository holen:
cd
aptitude install darcs
cd
darcs get --partial http://laconi.ca/darcs/

#
# memcached installieren
# Achtung: bei low traffic ergeben sich merkwürdige
# Effekte: incoming omb-posts sind nicht auf public timeline
# bis jemand lokal postet.
# Drum bei low traffic in config.php deaktivieren!
aptitude install memchached
#
#
cd
cd darcs
# den laconi.ca Code ins Webs-Verzeichnis kopieren:
cp -R * /var/www
# Das Avatarverzeichnis öffnen für den Webserver:
chgrp www-data /var/www/avatar
chmod g+w /var/www/avatar

# Die Datenbank anlegen:
cd /var/www
mysql -uroot -p -e 'create database laconica';
mysql -uroot -p -e "grant all privileges on laconica.* to laconicauser@localhost identified by 'laconicapasswort'";
mysql -uroot -p laconica < db/laconica.sql

# in httpd.conf ergänzen:
AddType image/x-icon .ico

# in /etc/apache2/sites-available/default steht nur:
NameVirtualHost [IP-Adresse]

<VirtualHost [IP-Adresse]>
ServerName io3.ch
ServerAlias www.io3.ch
DocumentRoot /var/www/
<Directory /var/www/>
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>

#
# maildaemon.php muss ausführbar sein
#
chmod +rx /var/www/scripts/maildaemon.php

# ejabberd als Jabber Server installieren
# mit dieser version ("original" jabber) ging's nicht: aptitude install jabber
# damit aber ziemlich schnell schon:
# gemäss http://www.chimeric.de/wiki/howto_ejabberd_on_debian
#
aptitude install ejabberd python-twisted python-pyopenssl
dpkg-reconfigure ejabberd

#
# htaccess an richtigen Ort kopieren:
cp htaccess.sample .htaccess

# weil laconica in /var/www Zeile 5:

RewriteBase /

# config an den richtigen Ort kopieren und editieren
cp config.php.sample config.php

bei mir sieht sie sinngemäss so aus:

(...)
#$extra_path = array("/opt/php-openid-2.0.1", "/usr/local/share/php");
$extra_path = array("/var/www/extlib");
set_include_path(implode(PATH_SEPARATOR, $extra_path) . PATH_SEPARATOR . get_include_path());

# We get called by common.php, $config is a tree with lots of config
# options
# These are for configuring your URLs

$config['site']['name'] = 'io3';
$config['site']['server'] = 'io3.ch';
$config['site']['path'] = '';
$config['site']['fancy'] = true;
$config['site']['theme'] = 'default';
#For contact email, defaults to $_SERVER["SERVER_ADMIN"]
#$config['site']['email'] = 'admin@example.net';
#Brought by...
$config['site']['broughtby'] = '468 inno';
$config['site']['broughtbyurl'] = 'http://468.ch/';
#If you don't want to let users register (say, for a one-person install)
#Crude but effective -- register everybody, then lock down
#$config['site']['closed'] = true;

# If you want logging sent to a file instead of syslog
#$config['site']['logfile'] = '/tmp/laconica.log';

# This is a PEAR DB DSN, see http://pear.php.net/manual/en/package.database.db.intro-dsn.php
# Set it to match your actual database

$config['db']['database'] = 'mysql://db-user:db-pw@localhost/db-name';
$config['db']['ini_db-name'] = $config['db']['schema_location'].'/laconica.ini';
# *** WARNING *** WARNING *** WARNING *** WARNING ***
# Setting debug to a non-zero value will expose your DATABASE PASSWORD to Web users.
# !!!!!! DO NOT SET THIS ON PRODUCTION SERVERS !!!!!! DB_DataObject's bug, btw, not
# ours.
# *** WARNING *** WARNING *** WARNING *** WARNING ***
#$config['db']['debug'] = 0;
#$config['db']['db_driver'] = 'MDB2';

#Database type. For mysql, these defaults are fine. For postgresql, set
#'quote_identifiers' to true and 'type' to 'pgsql':
$config['db']['quote_identifiers'] = false;
$config['db']['type'] = 'mysql';

#session_set_cookie_params(0, '/'. $config['site']['path'] .'/');
session_set_cookie_params(0, '');

#Standard fancy-url clashes prevented by not allowing nicknames on a blacklist
#Add your own here. Note: empty array by default
#$config['nickname']['blacklist'][] = 'scobleizer';

# xmpp
$config['xmpp']['enabled'] = true;
$config['xmpp']['server'] = 'dein.jabber.server';
$config['xmpp']['host'] = NULL; # Only set if different from server
$config['xmpp']['port'] = 5222;
$config['xmpp']['user'] = 'der user';
$config['xmpp']['encryption'] = true;
$config['xmpp']['resource'] = '468io3';
$config['xmpp']['password'] = 'verrat ich nicht';
$config['xmpp']['public'][] = '';
$config['xmpp']['debug'] = false;

#Default locale info
$config['site']['timezone'] = 'Europe/Zurich';
$config['site']['language'] = 'de_DE';
#Email info, used for all outbound email
$config['mail']['notifyfrom'] = 'absender@io3.ch';
$config['mail']['domain'] = 'io3.ch';
# See http://pear.php.net/manual/en/package.mail.mail.factory.php for options
$config['mail']['backend'] = 'smtp';
$config['mail']['params'] = array(
'host' => 'localhost',
'port' => 25,
);
#For incoming email, if enabled. Defaults to site server name.
$config['mail']['domain'] = 'io3.ch';


#exponential decay factor for tags, default 10 days
#raise this if traffic is slow, lower it if it's fast
$config['tag']['dropoff'] = 86400.0 * 10;

#optionally show non-local messages in public timeline
$config['public']['localonly'] = false;

#Do notice broadcasts offline
#If you use this, you must run the six offline daemons in the
#background. See the README for details.
$config['queue']['enabled'] = true;

#The following customise the behaviour of the various daemons:
$config['daemon']['piddir'] = '/var/run';
#
# trivial: user 'runasthis' muss lokal existieren
$config['daemon']['user'] = 'runasthis';
$config['daemon']['group'] = 'runasthis';

#
# auf false wegen: siehe weiter oben
$config['memcached']['enabled'] = false;
$config['memcached']['server'] = 'localhost';
$config['memcached']['port'] = 11211;

#Twitter integration source attribute. Note: default is Laconica
$config['integration']['source'] = 'Laconica';
Die Baustelle ist hier, aber nur mit Helm zu betreten. Die Installation wird wohl mehr down als up sein bis Weiteres. Und in Sachen favicon hab ich gelernt:
upload this file to the root directory of your website. For some reason the execute bit has to be set on this file for apache to use it. If you have shell access, type: "chmod +rx favicon.ico".

Then edit "/etc/httpd/conf/httpd.conf" and inserted the following line:

"AddType image/x-icon .ico"

Then restart your apacheserver, and voila!
Was jeweils unter dem Logo steht, ist definiert für's Deutsch in /var/www/locale/de_DE/LC_MESSAGES/laconica.po

#
# monit gab trouble, aktuell läuft der nicht
#
# MONITBESCHREIBUNG START
#
mit monit die laconica-daemons checken:

aptitude install monit
in /etc/monit/monitrc am ende einkommentieren:
include /etc/monit.d/*
dann /etc/monit.d/laconica so füllen (ACHTUNG: den Teil "468io3" anpassen an "$config['xmpp']['resource'] = 'was-hier-bei-dir-steht';" in config.php!):
check process xmppdaemon with pidfile /var/run/xmppdaemon.468io3-listen.pid
group laconica
start program = "/var/www/scripts/startdaemons.sh"
stop program = "/var/www/scripts/stopdaemons.sh"
if 5 restarts within 5 cycles then timeout

check process jabberqueuehandler with pidfile /var/run/jabberhandler.468io3-queuehandler.pid
group laconica
start program = "/var/www/scripts/startdaemons.sh"
stop program = "/var/www/scripts/stopdaemons.sh"
if 5 restarts within 5 cycles then timeout


check process publicqueuehandler with pidfile /var/run/publichandler.468io3-public.pid
group laconica
start program = "/var/www/scripts/startdaemons.sh"
stop program = "/var/www/scripts/stopdaemons.sh"
if 5 restarts within 5 cycles then timeout


check process xmppconfirmhandler with pidfile /var/run/xmppconfirmhandler.468io3-confirm.pid
group laconica
start program = "/var/www/scripts/startdaemons.sh"
stop program = "/var/www/scripts/stopdaemons.sh"
if 5 restarts within 5 cycles then timeout


check process smshandler with pidfile /var/run/smshandler.generic.pid
group laconica
start program = "/var/www/scripts/startdaemons.sh"
stop program = "/var/www/scripts/stopdaemons.sh"
if 5 restarts within 5 cycles then timeout


check process ombhandler with pidfile /var/run/ombhandler.generic.pid
group laconica
start program = "/var/www/scripts/startdaemons.sh"
stop program = "/var/www/scripts/stopdaemons.sh"
if 5 restarts within 5 cycles then timeout
Dann /etc/init.d/monit start
Dann checkt monit alle 3 Minuten ob die daemons noch laufen. Und startet sie alle, falls einer nicht mehr tut. Das ist etwas grob, zugegeben, aber für den Moment OK.

#
# MONIT BESCHREIBUNG STOP (monit ist aktuell off)
#

Und weil die laconica-daemons manchmal trotzdem nicht mehr tun, wie sie sollten noch das da:
neues file /irgendwo/stop-start
(make it executable!) mit:
#!/bin/sh
/var/www/scripts/stopdaemons.sh
sleep 5
/var/www/scripts/startdaemons.sh

in /etc/crontab diese Zeile ergänzen
(jede Stunde 1 Mal laufen lassen):

35 * * * * root /irgendwo/stop-start >> /dev/null 2>&1

3 Kommentare:

Mailhilfe hat gesagt…

Danke für den Beitrag.
Ich habe nun ein paar Stunden versucht das ganze unter SUSE 10.3 zu installieren.
Das hat bisher nicht funktioniert, ich bekomme nur eine leere Seite ohne igrendwelchen Inhalt (Kein Code) etc.
Hast du vielleicht noch eine Idee dazu?

Patrik Tschudin hat gesagt…

Uiuiui, grad gar nix? Da fragst Du mich was... Fernheilungen sind schwierig... Ich würd erst mal bei den üblichen Verdächtigen reinschauen: apache logfiles (bei mir unter /var/log/apache2/access.log und /var/log/apache2/error.log - gibt's 'ne Spur z.B. einer php-Fehlermeldung?) und /var/log/syslog und im Konfigurationsfile von laconi.ca config.php kannst mal in den Datenbank-Debug-Mode gehen indem Du

#$config['db']['debug'] = 0;

änderst in z.B.

$config['db']['debug'] = 5;

und den Output im Browser analysierst, wenn Du z.B. Deine Startseite aufrufst. Vielleicht hilft das weiter? Ich drück schon mal die Daumen. Doofe Nachfrage: Muss es unbedingt das doch schon etwas in die Jahre gekommene SuSE 10.3 sein???
toitoitoi!

Mailhilfe hat gesagt…

Nee ist klar, berühmte Fernheiler haben bisher auch das nicht geschafft.
Ein bisschen wollte ich mal schauen, ob auch andere Interesse haben...
Das Problem ist das ich zur Zeit keinen anderen Server zur Verfügung habe.
Ich werde deine Tipps erstmal verfolgen...