]> git.evergreen-ils.org Git - OpenSRF.git/blob - README
LP#1155446: add Debian/Ubuntu deps required for Python tests to pass
[OpenSRF.git] / README
1 Installing OpenSRF
2 ==================
3
4 Preamble: referenced user accounts
5 ----------------------------------
6
7 In subsequent sections, we will refer to a number of different accounts, as
8 follows:
9
10   * Linux user accounts:
11     ** The *user* Linux account is the account that you use to log onto the
12        Linux system as a regular user.
13     ** The *root* Linux account is an account that has system administrator
14        privileges. On Debian and Fedora you can switch to this account from
15        your *user* account by issuing the `su -` command and entering the
16        password for the *root* account when prompted. On Ubuntu you can switch
17        to this account from your *user* account using the `sudo su -` command
18        and entering the password for your *user* account when prompted.
19     ** The *opensrf* Linux account is an account that you will create as part
20        of installing OpenSRF. You can switch to this account from the *root*
21        account by issuing the `su - opensrf` command.
22
23 Installing prerequisites
24 ------------------------
25
26 OpenSRF has a number of prerequisite packages that must be installed
27 before you can successfully configure, compile, and install OpenSRF.
28 On Debian and Ubuntu, the easiest way to install these prerequisites
29 is to use the Makefile.install prerequisite installer.
30
31 Issue the following commands as the root user to install prerequisites
32 using the Makefile.install prerequisite installer, substituting your
33 operating system identifier for <osname> below:
34
35 ---------------------------------------------------------------------------
36 apt-get install make
37 make -f src/extras/Makefile.install <osname>
38 ---------------------------------------------------------------------------
39
40 Well-tested values for <osname> include:
41
42   * `debian-wheezy` for Debian 7.0
43   * `debian-squeeze` for Debian 6.0
44   * `ubuntu-lucid` for Ubuntu 10.04
45   * `ubuntu-precise` for Ubuntu 12.04
46   * `fedora` for Fedora 17 and later
47
48 Patches and suggestions for improvement from users of these distributions,
49 or others, are welcome!
50
51 When the prerequisite installer reaches the Perl module stage, you may 
52 be prompted for configuration of Comprehensive Perl Archive Network (CPAN)
53 on your server. You can generally accept the defaults by pressing <return>
54 for all of the prompts, except for the country configuration.
55
56 Preamble: Developer instructions
57 --------------------------------
58
59 [NOTE]
60 Skip this section if you are using an official release tarball downloaded
61 from http://evergreen-ils.org/downloads
62
63 Developers working directly with the source code from the Git repository,
64 rather than an official release tarball, must install some extra packages
65 and perform one step before they can proceed with the `./configure` step.
66
67 As the *root* Linux account, install the following packages:
68
69   * autoconf
70   * automake
71   * libtool
72
73 As the *user* Linux account, issue the following command in the OpenSRF
74 source directory to generate the configure script and Makefiles:
75
76 [source, bash]
77 ------------------------------------------------------------------------------
78 autoreconf -i
79 ------------------------------------------------------------------------------
80
81 Configuration and compilation instructions
82 ------------------------------------------
83
84 Use the `configure` command to configure OpenSRF, and the `make` command to
85 build OpenSRF. The default installation prefix (PREFIX) for OpenSRF is
86 `/opensrf/`.
87
88 If you are building OpenSRF for Evergreen, issue the following commands as
89 the *user* Linux account to configure and build OpenSRF:
90
91 ---------------------------------------------------------------------------
92 ./configure --prefix=/openils --sysconfdir=/openils/conf
93 make
94 ---------------------------------------------------------------------------
95
96 By default, OpenSRF includes C, Perl, and JavaScript support.
97 You can add the `--enable-python` option to the configure command
98 to build Python support and `--enable-java` for Java support.
99
100 Installation instructions
101 -------------------------
102
103 1. Once you have configured and compiled OpenSRF, issue the following
104    command as the *root* Linux account to install OpenSRF:
105 +
106 [source, bash]
107 ---------------------------------------------------------------------------
108 make install
109 ---------------------------------------------------------------------------
110
111 Create and set up the opensrf Unix user environment
112 ---------------------------------------------------
113
114 This user is used to start and stop all OpenSRF processes, and must own all
115 files contained in the PREFIX directory hierarchy. Issue the following
116 commands as the *root* Linux account to create the `opensrf` user and set up
117 its environment, substituting <PREFIX> with the value you passed to `--prefix`
118 in your configure command:
119
120 .Creating the `opensrf` user
121 [source, bash]
122 ---------------------------------------------------------------------------
123 useradd -m -s /bin/bash opensrf
124 echo "export PATH=\$PATH:/<PREFIX>/bin" >> /home/opensrf/.bashrc
125 passwd opensrf
126 chown -R opensrf:opensrf /<PREFIX>
127 ---------------------------------------------------------------------------
128
129 Define your public and private OpenSRF domains
130 ----------------------------------------------
131
132 For security purposes, OpenSRF uses Jabber domains to separate services
133 into public and private realms. Throughout these instructions, we will use
134 the example domains `public.localhost` and `private.localhost`. 
135
136 On a single-server system, the easiest way to define public and private
137 domains is to define separate hostnames by adding entries to the `/etc/hosts`
138 file. Here are entries that you could add to a stock `/etc/hosts` file for our
139 example domains:
140
141 .Example added entries for `/etc/hosts`
142 ---------------------------------------------------------------------------
143 127.0.1.2       public.localhost        public
144 127.0.1.3       private.localhost       private
145 ---------------------------------------------------------------------------
146
147 Adjust the system dynamic library path
148 --------------------------------------
149
150 Add `<PREFIX>/lib/` to the system's dynamic library path, and then run
151 `ldconfig` as the *root* Linux account.
152
153 On Debian, Ubuntu, and Fedora systems, run the following commands as the *root*
154 Linux account:
155
156 .Adjusting the system dynamic library path
157 [source, bash]
158 ---------------------------------------------------------------------------
159 echo <PREFIX>/lib > /etc/ld.so.conf.d/opensrf.conf
160 ldconfig
161 ---------------------------------------------------------------------------
162
163 On most other systems, you can add these entries to `/etc/ld.so.conf`, or
164 create a file within the `/etc/ld.so.conf.d/` directory, and then run
165 `ldconfig` as the *root* Linux account.
166
167 Configure the ejabberd server
168 -----------------------------
169
170 OpenSRF requires an XMPP (Jabber) server. For performance reasons, ejabberd is
171 the Jabber server of choice for the OpenSRF project. In most cases, you only
172 have to make a few changes to the default `ejabberd.cfg` file to make ejabberd
173 work for OpenSRF. 
174
175 1. Stop ejabberd before making any changes to its configuration by issuing the
176    following command as the *root* Linux account:
177 +
178 .(Debian / Ubuntu) Stopping ejabberd
179 [source, bash]
180 ---------------------------------------------------------------------------
181 /etc/init.d/ejabberd stop
182 ---------------------------------------------------------------------------
183 +
184 .(Fedora) Stopping ejabberd
185 [source, bash]
186 ---------------------------------------------------------------------------
187 systemctl stop ejabberd.service
188 ---------------------------------------------------------------------------
189 +
190 2. Open `/etc/ejabberd/ejabberd.cfg` and make the following
191 changes:
192   a. Define your public and private domains in the `hosts` directive. For
193    example:
194 +
195 ---------------------------------------------------------------------------
196 {hosts, ["localhost", "private.localhost", "public.localhost"]}.
197 ---------------------------------------------------------------------------
198 +
199   b. Comment out the `mod_offline` directive
200   c. Increase the `max_user_sessions` value to 10000
201   d. Change all `max_stanza_size` values to 2000000
202   e. Change all `maxrate` values to 500000 
203 +
204 3. Restart the ejabberd server to make the changes take effect:
205 +
206 .(Debian / Ubuntu) Starting ejabberd
207 [source, bash]
208 ---------------------------------------------------------------------------
209 /etc/init.d/ejabberd start
210 ---------------------------------------------------------------------------
211 +
212 .(Fedora) Starting ejabberd
213 [source, bash]
214 ---------------------------------------------------------------------------
215 systemctl start ejabberd.service
216 ---------------------------------------------------------------------------
217
218 Create the OpenSRF Jabber users
219 -------------------------------
220
221 On each domain, you need two Jabber users to manage the OpenSRF communications:
222
223   * a `router` user, to whom all requests to connect to an OpenSRF service
224     will be routed; this Jabber user must be named `router`
225   * an `opensrf` user, which clients use to connect to OpenSRF services; this
226     user can be named anything you like
227
228 Create the Jabber users by issuing the following commands as the *root* Linux
229 account. Substitute `<password>` for your chosen passwords for each user
230 respectively:
231
232 .Creating the OpenSRF Jabber users
233 [source, bash]
234 ---------------------------------------------------------------------------
235 ejabberdctl register router private.localhost <password>
236 ejabberdctl register opensrf private.localhost <password>
237 ejabberdctl register router public.localhost <password>
238 ejabberdctl register opensrf public.localhost <password>
239 ---------------------------------------------------------------------------
240
241 Update the OpenSRF configuration files
242 --------------------------------------
243
244 About the OpenSRF configuration files
245 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
246 There are several configuration files that you must update to make OpenSRF
247 work. SYSCONFDIR is `/opensrf/etc` by default, or the value that you passed to
248 `--sysconfdir` during the configuration phase.
249
250   * `SYSCONFDIR/opensrf.xml` - this file lists the services that this
251     OpenSRF installation supports; if you create a new OpenSRF service,
252     you need to add it to this file.
253       ** The `<hosts>` element at the bottom of the file lists the services
254          that should be started for each hostname. You can force the system
255          to use `localhost`, so in most cases you will leave this section
256          as-is.
257     
258   * `SYSCONFDIR/opensrf_core.xml` - this file lists the Jabber connection
259     information that will be used for the system, as well as determining
260     logging verbosity and defining which services will be exposed on the
261     HTTP gateway.
262
263   * `~/.srfsh.xml` - this file gives a Linux account the ability to use
264     the `srfsh` interpreter to communicate with OpenSRF services.
265
266 Updating the OpenSRF configuration files
267 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268   1. As the *opensrf* Linux account, copy the example configuration files
269      to create your locally customizable OpenSRF configuration files:
270 +
271 .Copying the example OpenSRF configuration files
272 [source,bash]
273 ---------------------------------------------------------------------------
274 cd SYSCONFDIR
275 cp opensrf_core.xml.example opensrf_core.xml
276 cp opensrf.xml.example opensrf.xml
277 ---------------------------------------------------------------------------
278 +
279   2. Edit the `SYSCONFDIR/opensrf_core.xml` file to update the four username
280      / password pairs to match the Jabber user accounts you just created:
281
282     a. `<config><opensrf>` = use the private Jabber `opensrf` user
283     b. `<config><gateway>` = use the public Jabber `opensrf` user
284     c. `<config><routers><router>` = use the public Jabber `router` user
285     d. `<config><routers><router>` = use the private Jabber `router` user
286   3. Create a `.srfsh.xml` file in the home directory of each user
287      that you want to use `srfsh` to communicate with OpenSRF services. For
288      example, to enable the *opensrf* Linux account to use `srfsh`:
289     a. `cp SYSCONFDIR/srfsh.xml.example ~/.srfsh.xml`
290     b. Open `~/.srfsh.xml` in your text editor of choice and update the
291        password to match the password you set for the Jabber `opensrf` user
292        at the `private.localhost` domain.
293
294 Starting and stopping OpenSRF services
295 --------------------------------------
296
297 To start all OpenSRF services with a hostname of `localhost`, issue the
298 following command as the *opensrf* Linux account:
299
300 [source, bash]
301 ---------------------------------------------------------------------------
302 osrf_control --localhost --start-all
303 ---------------------------------------------------------------------------
304
305 To stop all OpenSRF services with a hostname of `localhost`, issue the
306 following command as the *opensrf* Linux account:
307
308 [source,bash]
309 ---------------------------------------------------------------------------
310 osrf_control --localhost --stop-all
311 ---------------------------------------------------------------------------
312
313 Testing the default OpenSRF services
314 ------------------------------------
315
316 By default, OpenSRF ships with an `opensrf.math` service that performs basic
317 calculations involving two integers. Once you have started the OpenSRF
318 services, test the services as follows:
319
320 1. Start the `srfsh` interactive OpenSRF shell by issuing the following
321    command as the *opensrf* Linux account:
322 +
323 .Starting the `srfsh` interactive OpenSRF shell
324 [source,bash]
325 ---------------------------------------------------------------------------
326 srfsh
327 ---------------------------------------------------------------------------
328 +
329 2. Issue the following request to test the `opensrf.math` service:
330 +
331 ---------------------------------------------------------------------------
332 srfsh# request opensrf.math add 2,2
333 ---------------------------------------------------------------------------
334 +
335 You should receive the value `4`.
336
337 Troubleshooting note for Python users
338 -------------------------------------
339
340 If you are running a Python client and trying to connect to OpenSRF running on
341 localhost rather than a hostname that can be resolved via DNS, you will
342 probably receive exceptions about `dns.resolver.NXDOMAIN`. If this happens,
343 you need to install the `dnsmasq` package, configure it to serve up a DNS
344 entry for localhost, and point your local DNS resolver to `dnsmasq`. For example,
345 on Ubuntu you can issue the following commands as the *root* Linux account:
346
347 .(Debian / Ubuntu) Installing and starting `dnsmasq`
348 [source, bash]
349 ---------------------------------------------------------------------------
350 aptitude install dnsmasq
351 /etc/init.d/dnsmasq restart
352 ---------------------------------------------------------------------------
353
354 Then edit `/etc/resolv.conf` and ensure that `nameserver 127.0.0.1` is the
355 first entry in the file.
356
357 Getting help
358 ------------
359
360 Need help installing or using OpenSRF? Join the mailing lists at
361 http://evergreen-ils.org/listserv.php or contact us on the Freenode
362 IRC network on the #evergreen channel.