Instructions for setting up Ejabberd with J2J / ICQ transport (with correct encoding) on ​​Ubuntu Server


    Today we will be setting up our own jabber server for on Ubuntu Server Edition.
    On this server there will be transport to ICQ and jabber. Logs will be written to the directory. Logs can be conveniently viewed from a mobile device (fancyindex + htpasswd + fail2ban).
    It is understood that at least on Linux you already know. It is also worth noting: the instruction is a guiding light, gives a general direction and does not urge to fulfill it 100% as it is written in it. Also, it does not cover 100% of the settings, you need to be able to configure the web server and work with mysql.

    Further for an example I will use as a hoster. Naturally, various pieces of instructions can be used on any other distribution / hoster.

    Stage 1. Preparation of a server environment.

    We register with the hoster, create a scale-server with ubuntu lucid 10.04 LTS 32-bit, 512MB of memory, 5GB SAS.
    After obtaining root access and other details, we go to the server.
    We wait until dpkg updates the system to the current state:

    ps uxa | egrep '(firstrun|local|apt|dpkg)'

    Replace /etc/apt/sources.list with: Create a file /etc/apt/apt.conf.d/03test with the contents: Add the Spectrum key (our future Jabber transport): We replace hostname for convenience: We edit the files in the output, replacing the lines with the we need, and then we change hostname: Configure sudo for our user: At the end of the file, enter:

    deb lucid main restricted
    deb lucid-updates main restricted
    deb lucid universe
    deb lucid-updates universe
    deb lucid multiverse
    deb lucid-updates multiverse
    deb lucid-backports main restricted universe multiverse
    deb lucid partner
    deb lucid-security main restricted
    deb lucid-security universe
    deb lucid-security multiverse
    deb lucid spectrum

    APT::Install-Recommends "false";
    APT::Install-Suggests "false";

    sudo apt-key adv --recv-keys --keyserver 47A944AF1905866A

    fgrep -r $(uname -n) /etc



    user ALL=(ALL) ALL

    We configure access by key (google how it is done, keywords ssh-agent, ssh-keygen -t rsa, ssh-copy-id) for the user user created by default.

    We try to log in as user, and also check the operation of sudo su. After that, edit / etc / ssh / sshd_config.

    Required options: After that, we restart SSH (here, be careful, we have denied access by password, as well as root. We can fix the jambs here through VNC in the case of Clodo, or through KVM, in general, using physical access to the server console ): Russify a system with UTF-8 support: Edit the file /var/lib/locales/supported.d/locale.gen and the file / etc / environment Generate locales:

    PermitRootLogin no
    PasswordAuthentication no
    RSAAuthentication yes
    PubkeyAuthentication yes

    service ssh restart

    ru_RU.UTF-8 UTF-8
    en_US.UTF-8 UTF-8


    dpkg-reconfigure locales

    At this point, you can go to the server by specifying UTF-8 in the SSH client. Russian language will appear.

    We add to /etc/rc.local: this will save money on the server (relevant for clodo). Install the necessary packages: During installation, the system will ask for the root password from MySQL, how the mail server will function (select the Internet Site, domain name In the zone for we indicate: We configure aliases by editing the / etc / aliases file: Generate aliases for postfix: Send a test letter: We look at the logs /var/log/, as well as the presence of the letter in the mailbox If everything is ok, let's go further! Configure reboot notifications by email.

    sysctl -w vm.swappiness=100
    su -c 'echo 0 > /sys/devices/system/xenmgm/xenmgm0/memmin_bytes'
    su -c 'echo 60000000 > /sys/devices/system/xenmgm/xenmgm0/reserve_free_bytes'

    apt-get install libpurple0-minimal htop strace apache2 mysql-server spectrum python python-twisted python-imaging postfix iptables fail2ban mailutils mpack subversion A (ваш IP-адрес) MX 10 SRV 0 0 5269 SRV 0 0 5222 SRV 0 0 5269 TXT "v=spf1 a mx ~all"
    * CNAME @



    mail -s test user [нажимаем enter]
    CC: [нажимаем enter]
    [нажимаем ctrl+d]

    As user user, do the following:

    crontab -e

    Write the line:
    @reboot echo "server rebooted at `date`" | mail -s "Server `uname -n` Rebooted!"

    Attention, if you specify the +% modifier in date, put a percent before the percentage, for example: $ (date + \% m. \% D), or `date + \% m. \% D` otherwise the crown will be coveted with incomprehensible errors.

    Stage 2. Setting up our Jabber.

    Download the ejabberd distribution. Installation is simple. We select the language, carefully read the entire license agreement, select “y” in response to the question: “Do you accept the terms of the license agreement? [y / n]: ”, select the installation directory (leave the default /opt/ejabberd-2.1.6), domain name, admin admin user name, administrator password. We refuse cluster settings: Ejabberd will be installed. Server management occurs from the /opt/ejabberd-2.1.6/bin directory. For more details, see the ejabberd documentation. Now we are interested in /opt/ejabberd-2.1.6/conf/ejabberd.cfg, edit it by adding the necessary lines: to the section {modules ,: to the section {listen ,:

    cd /usr/src
    gunzip ejabberd-2.1.6-linux-x86-installer.bin.gz
    chmod +x ejabberd-2.1.6-linux-x86-installer.bin

    Кластер [y/N]: N

    Программа готова к установке ejabberd на ваш компьютер.

    Вы хотите продолжить? [Y/n]: Y

    {mod_log_chat, [{path, "/opt/ejabberd-2.1.6/www"}, {format, html}]},

    {8888, ejabberd_service, [
    {access, all},
    {shaper_rule, fast},
    {ip, {127, 0, 0, 1}},
    {hosts, ["”, ""],
    [{password, "iearhg98a3hg89h3498gha9"}]

    {8883, ejabberd_service, [
    {access, all},
    {shaper_rule, fast},
    {ip, {127, 0, 0, 1}},
    {hosts, [""],
    [{password, "ojer0jg0a9jg09j0gjreg0"}]

    We make sure that the /opt/ejabberd-2.1.6/www directory is created and has permissions of 0755.

    Now we need to compile the mod_log_chat module and install it: Now run and test ejabberd, write a message to someone, and look at the logs. Everything should work. Stop ejabberd. Add to /etc/rc.local before exit 0:

    cd /usr/src
    svn co
    cp ejabberd-modules/mod_log_chat/trunk/src/mod_log_chat.erl /opt/ejabberd-2.1.6/
    cd /opt/ejabberd-2.1.6
    bin/erlc -I includes/ejabberd/include mod_log_chat.erl
    mv mod_log_chat.beam lib/ejabberd-2.1.6/ebin/
    rm mod_log_chat.erl

    cd /opt/ejabberd-2.1.6/bin

    sleep 10
    su -c '/opt/ejabberd-2.1.6/bin/start'

    Stage 3. We configure transport on ICQ.

    We will use pyicq-t.

    Adding user jabber: Download the pyicqt with in homework to jabber and extract transport. Edit config.xml, set everything as in the config above, server, port 8888, secret token - password, encoding cp1251,, 5190, language ru - the config speaks for itself. append to /etc/rc.local before exit 0:

    useradd -m -s /bin/bash jabber
    passwd jabber
    su jabber

    tar zvxf pyicqt-
    mv pyicqt- pyicqt
    cd pyicqt
    cp config_example.xml config.xml

    su -c 'python /home/jabber/pyicqt/ > /home/jabber/pyicqt/log 2>&1 &' - jabber

    Step 4. Configure j2j transport:

    cd /etc/spectrum/

    The mysql commands create the user j2j with the password pass and the database j2j. Editing spectrum.cfg: Pay attention to log_areas, it is better to leave the field empty, otherwise there will be a lot of garbage in the / var / log / spectrum log. Add to /etc/rc.local before exit 0:

    mysql -u j2j -p'pass' j2j < mysql_schema.sql
    mv spectrum.cfg.example spectrum.cfg


    /etc/init.d/spectrum start

    Step 5. Set up viewing logs:

    Lets say apache2 is set up in /home/user/www/ to work with

    Create a symlink:
    lrwxrwxrwx 1 root root 24-03-03-04 13:24 chat -> /opt/ejabberd-2.1.6/www/

    Create /opt/ejabberd-2.1.6/www/.htaccess with the contents: Generate file / opt / ejabberd-2.1.6 / www / .htpasswd can, for example, be this: fail2ban will protect us from password guessing. Do not forget to add the necessary services to startup: That's all. After a reboot, if everything was done correctly, the server will work. For use, I recommend the PSI + client with options for automatic user authorization and automatic user nicknames. This is a hidden option, added to options / contactlist:

    Options +Indexes
    IndexOptions FancyIndexing
    IndexOptions +SuppressSize
    IndexOrderDefault Descending Date
    AuthType Basic
    AuthName "wat"
    AuthUserFile /opt/ejabberd-2.1.6/www/.htpasswd
    Require valid-user

    update-rc.d SERVICENAME defaults

    bool options.contactlist.resolve-nicks-on-contact-add true

    For Android, I recommend Xabber.

    To test and configure while reading the instructions, you need to look and use:

    logs : /opt/ejabberd-2.1.6/logs These logs will tell you why the server did not start, what generally happens, where the problem is in the syntax, etc.

    Logs Spectrum: / var / log / spectrum
    Similarly for problems, the Spectrum will

    flood the Ejabberctl log : /opt/ejabberd-2.1.6/bin/ejabberdctl
    Used to create, delete, set a user password. Ultra-useful utility, until they figured out the roster, automatic user authorization and automatic nicknames.

    Documentation sites:

    In contact with you, write about typos and errors in the Habrahta or comments, I will correct.

    Also popular now: