INSTALL.chat.md 5.81 KB
Newer Older
Rodrigo Souto's avatar
Rodrigo Souto committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Automatic XMPP/Chat Setup
=========================

Since Noosfero 1.2, the XMPP/Chat can be installed via `noosfero-chat` Debian
package. So you don't need to follow the manual instructions here if you
already have it installed on your system.

But if you are going to install the `noosfero-chat` package on a system that
already has `noosfero` older 1.2 installed then you need to check if apache's
configuration file `/etc/apache2/sites-available/noosfero` has this line below:

     Include /usr/share/noosfero/util/chat/apache/xmpp.conf

Manual XMPP/Chat Setup
======================
16

17 18
The samples of config file to configure a XMPP/BOSH server with ejabberd,
postgresql and apache2 can be found at util/chat directory.
Joenio Costa's avatar
Joenio Costa committed
19

20 21
This setup supposes that you are using Noosfero installed via Debian package
in a production environment.
Joenio Costa's avatar
Joenio Costa committed
22

23
Steps
Rodrigo Souto's avatar
Rodrigo Souto committed
24
-----
25 26 27

This is a step-by-step guide to get a XMPP service working, in a Debian system.

28
## 1. Install the required packages
29

30
    # apt-get install ejabberd odbc-postgresql librestclient-ruby ruby1.8-dev
31
    # gem install SystemTimer
32

33
## 2. Ejabberd configuration
34

35
    # cp /usr/share/noosfero/util/chat/ejabberd.cfg /etc/ejabberd/
36

37
Edit the /etc/ejabberd/ejabberd.cfg file and set your domain on the first 2 lines.
38

39
## 3. Configuring Postgresql
40

41 42
Give permission to noosfero user create new roles, login as
postgres user and execute:
43

44 45
    $ psql
    postgres=# GRANT CREATE ON DATABASE noosfero TO noosfero;
46

47 48
Change the postgresql authentication method to md5 instead of ident,
add the following line to the file /etc/postgresql/8.4/main/pg_hba.conf:
49

50 51
   # Noosfero user
   local   noosfero    noosfero                          md5
52

53
(add this line before the following line)
54

55 56
   # "local" is for Unix domain socket connections only
   local   all         all                               ident
57

58
Restart postgresql server:
59

60
    # service postgresql restart
61

62
Login as noosfero user, and execute:
63

64
    $ psql -U noosfero -W noosfero < /usr/share/noosfero/util/chat/postgresql/ejabberd.sql
65

66
(see database password in the /etc/noosfero/database.yml file)
67

68
This will create a new schema inside the noosfero database, called `ejabberd`.
69

70 71
Note that there should be at least one domain with `is_default = true` in
`domains` table, otherwise people won't be able to see their friends online.
72

73
## 4. ODBC configuration
74

75
Create the following files:
76

77 78
    # cp /usr/share/noosfero/util/chat/odbc.ini /etc/
    # cp /usr/share/noosfero/util/chat/odbcinst.ini /etc/
79

80 81
Edit the odbc.ini file and set the password for the database user, see
the file /etc/noosfero/database.yml to get the password.
82

83
Adjust premissions:
84

85 86
    # chmod 640 /etc/odbc.ini
    # chown ejabberd /etc/odbc.ini
87

88
## 4.1 testing all:
89

90
    # isql 'PostgreSQLEjabberdNoosfero'
Daniela Feitosa's avatar
Daniela Feitosa committed
91

92
If the configuration was done right, the message "Connected!" will be displayed.
93

94
## 5. Enabling kernel polling and SMP in `/etc/default/ejabberd`
95

96 97
    POLL=true
    SMP=auto
98

99
## 6. Increase the file descriptors limit for user ejabberd
100

101
### 6.1. Uncomment this line in file `/etc/pam.d/su`:
102

103
    session required pam_limits.so
104

105
### 6.2. Add this lines to file `/etc/security/limits.conf`:
106

107 108
    ejabberd       hard    nofile  65536
    ejabberd       soft    nofile  65536
109 110 111

Now, test the configuration:

112
    # cat /proc/<EJABBERD_BEAM_PROCESS_PID>/limits
113

114
## 7. Apache Configuration
115

116
Apache server must be configurated as follow:
117

118
`/etc/apache2/sites-enabled/noosfero`:
119

120 121
    RewriteEngine On
    Include /usr/share/noosfero/util/chat/apache/xmpp.conf
122

123
`/etc/apache2/apache2.conf`:
124

125 126 127 128 129 130 131 132 133
    <IfModule mpm_worker_module>
       StartServers          8
       MinSpareThreads       25
       MaxSpareThreads       75
       ThreadLimit           128
       ThreadsPerChild       128
       MaxClients            2048
       MaxRequestsPerChild   0
    </IfModule>
134 135 136

Note: module proxy_http must be enabled:

137
    # a2enmod proxy_http
138

139
Restart services:
140

141 142 143
    # service ejabberd restart
    # service noosfero restart
    # service apache2 restart
144

145
## 8. Test Apache Configuration
146

147
Open in your browser the address:
148

149
    http://<yout domain>/http-bind
150

151
You should see a page with a message like that:
152

153 154 155 156
   ejabberd mod_http_bind
   An implementation of XMPP over BOSH (XEP-0206)
   This web page is only informative. To use HTTP-Bind you need a Jabber/XMPP
   client that supports it.
157

158
## 9. Test chat session
159

Rodrigo Souto's avatar
Rodrigo Souto committed
160 161
Run `./script/noosfero-test-chat-session`. If you have luck, should see
something like that:
162

163 164 165 166 167 168 169 170 171 172 173
Ruby-BOSH - SEND
<body window="5" rid="60265" xmlns="http://jabber.org/protocol/httpbind" xmlns:xmpp="urn:xmpp:xbosh" to="vagrant-debian-squeeze.vagrantup.com" wait="30" xmpp:version="1.0" hold="1"/>
Ruby-BOSH - SEND
<body rid="60266" xmlns="http://jabber.org/protocol/httpbind" sid="24cdfc43646a2af1059a7060b677c2e11b26f34f" xmlns:xmpp="urn:xmpp:xbosh" xmpp:version="1.0"><auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">Z3Vlc3RAdmFncmFudC1kZWJpYW4tc3F1ZWV6ZS52YWdyYW50dXAuY29tAGd1ZXN0ADEzZTFhYWVlYjRhYjZlMTA0MmRkNWI1YWY0MzM4MjA1OGJiOWZmNzk=</auth></body>
Ruby-BOSH - SEND
<body xmpp:restart="true" rid="60267" xmlns="http://jabber.org/protocol/httpbind" sid="24cdfc43646a2af1059a7060b677c2e11b26f34f" xmlns:xmpp="urn:xmpp:xbosh" xmpp:version="1.0"/>
Ruby-BOSH - SEND
<body rid="60268" xmlns="http://jabber.org/protocol/httpbind" sid="24cdfc43646a2af1059a7060b677c2e11b26f34f" xmlns:xmpp="urn:xmpp:xbosh" xmpp:version="1.0"><iq type="set" xmlns="jabber:client" id="bind_29330"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>bosh_9631</resource></bind></iq></body>
Ruby-BOSH - SEND
<body rid="60269" xmlns="http://jabber.org/protocol/httpbind" sid="24cdfc43646a2af1059a7060b677c2e11b26f34f" xmlns:xmpp="urn:xmpp:xbosh" xmpp:version="1.0"><iq type="set" xmlns="jabber:client" id="sess_21557"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq></body>
=> ["guest@vagrant-debian-squeeze.vagrantup.com", "24cdfc43646a2af1059a7060b677c2e11b26f34f", 60270]