]> git.evergreen-ils.org Git - OpenSRF.git/blob - README
LP#1473479 Syslog configuration adoption
[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* Linux account to install 
32 prerequisites using the Makefile.install prerequisite installer, substituting 
33 your operating system identifier for <osname> below:
34
35 [source, bash]
36 ---------------------------------------------------------------------------
37 apt-get install make
38 make -f src/extras/Makefile.install <osname>
39 ---------------------------------------------------------------------------
40
41 Well-tested values for <osname> include:
42
43   * `debian-jessie` for Debian 8.0
44   * `debian-wheezy` for Debian 7.0
45   * `ubuntu-precise` for Ubuntu 12.04
46   * `ubuntu-trusty` for Ubuntu 14.04
47   * `ubuntu-xenial` for Ubuntu 16.04
48   * `fedora` for Fedora 17 and later
49
50 Patches and suggestions for improvement from users of these distributions,
51 or others, are welcome!
52
53 When the prerequisite installer reaches the Perl module stage, you may 
54 be prompted for configuration of Comprehensive Perl Archive Network (CPAN)
55 on your server. You can generally accept the defaults by pressing <return>
56 for all of the prompts, except for the country configuration.
57
58 Preamble: Developer instructions
59 --------------------------------
60
61 [NOTE]
62 Skip this section if you are using an official release tarball downloaded
63 from http://evergreen-ils.org/downloads
64
65 Developers working directly with the source code from the Git repository,
66 rather than an official release tarball, must install some extra packages
67 and perform one step before they can proceed with the `./configure` step.
68
69 As the *root* Linux account, install the following packages:
70
71   * autoconf
72   * automake
73   * libtool
74
75 As the *user* Linux account, issue the following command in the OpenSRF
76 source directory to generate the configure script and Makefiles:
77
78 [source, bash]
79 ------------------------------------------------------------------------------
80 autoreconf -i
81 ------------------------------------------------------------------------------
82
83 Configuration and compilation instructions
84 ------------------------------------------
85
86 Use the `configure` command to configure OpenSRF, and the `make` command to
87 build OpenSRF. The default installation prefix (PREFIX) for OpenSRF is
88 `/opensrf/`.
89
90 If you are building OpenSRF for Evergreen, issue the following commands as
91 the *user* Linux account to configure and build OpenSRF:
92
93 [source, bash]
94 ---------------------------------------------------------------------------
95 ./configure --prefix=/openils --sysconfdir=/openils/conf
96 make
97 ---------------------------------------------------------------------------
98
99 By default, OpenSRF includes C, Perl, and JavaScript support.
100 You can add the `--enable-python` option to the configure command
101 to build Python support and `--enable-java` for Java support.
102
103 Installation instructions
104 -------------------------
105
106 1. Once you have configured and compiled OpenSRF, issue the following
107    command as the *root* Linux account to install OpenSRF:
108 +
109 [source, bash]
110 ---------------------------------------------------------------------------
111 make install
112 ---------------------------------------------------------------------------
113
114 Create and set up the opensrf Unix user environment
115 ---------------------------------------------------
116
117 This user is used to start and stop all OpenSRF processes, and must own all
118 files contained in the PREFIX directory hierarchy. Issue the following
119 commands as the *root* Linux account to create the `opensrf` user and set up
120 its environment, substituting <PREFIX> with the value you passed to `--prefix`
121 in your configure command:
122
123 .Creating the `opensrf` user
124 [source, bash]
125 ---------------------------------------------------------------------------
126 useradd -m -s /bin/bash opensrf
127 echo "export PATH=\$PATH:/<PREFIX>/bin" >> /home/opensrf/.bashrc
128 passwd opensrf
129 chown -R opensrf:opensrf /<PREFIX>
130 ---------------------------------------------------------------------------
131
132 Define your public and private OpenSRF domains
133 ----------------------------------------------
134
135 For security purposes, OpenSRF uses Jabber domains to separate services
136 into public and private realms. Throughout these instructions, we will use
137 the example domains `public.localhost` and `private.localhost`. 
138
139 On a single-server system, the easiest way to define public and private
140 domains is to define separate hostnames by adding entries to the `/etc/hosts`
141 file. Here are entries that you could add to a stock `/etc/hosts` file for our
142 example domains:
143
144 .Example added entries for `/etc/hosts`
145 [source, bash]
146 ---------------------------------------------------------------------------
147 127.0.1.2       public.localhost        public
148 127.0.1.3       private.localhost       private
149 ---------------------------------------------------------------------------
150
151 Adjust the system dynamic library path
152 --------------------------------------
153
154 Add `<PREFIX>/lib/` to the system's dynamic library path, and then run
155 `ldconfig` as the *root* Linux account.
156
157 On Debian, Ubuntu, and Fedora systems, run the following commands as the *root*
158 Linux account:
159
160 .Adjusting the system dynamic library path
161 [source, bash]
162 ---------------------------------------------------------------------------
163 echo <PREFIX>/lib > /etc/ld.so.conf.d/opensrf.conf
164 ldconfig
165 ---------------------------------------------------------------------------
166
167 On most other systems, you can add these entries to `/etc/ld.so.conf`, or
168 create a file within the `/etc/ld.so.conf.d/` directory, and then run
169 `ldconfig` as the *root* Linux account.
170
171 Configure the ejabberd server
172 -----------------------------
173
174 OpenSRF requires an XMPP (Jabber) server. For performance reasons, ejabberd is
175 the Jabber server of choice for the OpenSRF project. In most cases, you only
176 have to make a few changes to the default configuration file to make ejabberd
177 work for OpenSRF. 
178
179 1. Stop ejabberd before making any changes to its configuration by issuing the
180    following command as the *root* Linux account:
181 +
182 .(Debian / Ubuntu 14.04) Stopping ejabberd
183 [source, bash]
184 ---------------------------------------------------------------------------
185 /etc/init.d/ejabberd stop
186 ---------------------------------------------------------------------------
187 +
188 .(Fedora / Ubuntu 16.04) Stopping ejabberd
189 [source, bash]
190 ---------------------------------------------------------------------------
191 systemctl stop ejabberd.service
192 ---------------------------------------------------------------------------
193 +
194 2. Edit the ejabberd config file.
195 +
196 (Debian Wheezy / Ubuntu 14.04) Ejabberd 2.x.x::
197 Open `/etc/ejabberd/ejabberd.cfg` and make the following
198 changes:
199   a. Define your public and private domains in the `hosts` directive. For
200    example:
201 +
202 [source, bash]
203 ---------------------------------------------------------------------------
204 {hosts, ["localhost", "private.localhost", "public.localhost"]}.
205 ---------------------------------------------------------------------------
206 +
207   b. Change all `max_stanza_size` values to 2000000
208   c. Change all `maxrate` values to 500000
209   d. Increase the `max_user_sessions` value to 10000
210   e. Comment out the `mod_offline` directive
211 +
212 (Debian Jessie) Ejabberd 13.x and 14.x::
213 Open `/etc/ejabberd/ejabberd.yml` and make the following
214 changes:
215   a. Define your public and private domains in the `hosts` directive. For
216    example:
217 +
218 [source, bash]
219 ---------------------------------------------------------------------------
220 hosts:
221   - "localhost"
222   - "private.localhost"
223   - "public.localhost"
224 ---------------------------------------------------------------------------
225 +
226   b. Change all `max_stanza_size` values to 2000000
227   c. Change `shaper:` `normal` and `fast` values to 500000
228   d. Increase the `max_user_sessions:` `all:` value to 10000
229   e. Comment out the `mod_offline` directive
230 +
231 -----------------------
232 ##mod_offline:
233     ##access_max_user_messages: max_user_offline_messages
234 -----------------------
235 +
236 (Ubuntu 16.04) Ejabberd 16.x::
237 Open `/etc/ejabberd/ejabberd.yml` and make the following
238 changes:
239   a. Define your public and private domains in the `hosts` directive. For
240    example:
241 +
242 [source, bash]
243 ---------------------------------------------------------------------------
244 hosts:
245   - "localhost"
246   - "private.localhost"
247   - "public.localhost"
248 ---------------------------------------------------------------------------
249 +
250   b. Change all `max_stanza_size` values to 2000000
251   c. Change `auth_password_format` to plain
252   d. Change `shaper:` `normal` and `fast` values to 500000
253   e. Increase the `max_user_sessions:` `all:` value to 10000
254   f. Comment out the `mod_offline` directive
255 +
256 -----------------------
257 ##mod_offline:
258     ##access_max_user_messages: max_user_offline_messages
259 -----------------------
260 +
261 3. Restart the ejabberd server to make the changes take effect:
262 +
263 .(Debian / Ubuntu 14.04) Starting ejabberd
264 [source, bash]
265 ---------------------------------------------------------------------------
266 /etc/init.d/ejabberd start
267 ---------------------------------------------------------------------------
268 +
269 .(Fedora / Ubuntu 16.04) Starting ejabberd
270 [source, bash]
271 ---------------------------------------------------------------------------
272 systemctl start ejabberd.service
273 ---------------------------------------------------------------------------
274
275 Create the OpenSRF Jabber users
276 -------------------------------
277
278 On each domain, you need two Jabber users to manage the OpenSRF communications:
279
280   * a `router` user, to whom all requests to connect to an OpenSRF service
281     will be routed; this Jabber user must be named `router`
282   * an `opensrf` user, which clients use to connect to OpenSRF services; this
283     user can be named anything you like
284
285 Create the Jabber users by issuing the following commands as the *root* Linux
286 account. Substitute `<password>` for your chosen passwords for each user
287 respectively:
288
289 .Creating the OpenSRF Jabber users
290 [source, bash]
291 ---------------------------------------------------------------------------
292 ejabberdctl register router private.localhost <password>
293 ejabberdctl register opensrf private.localhost <password>
294 ejabberdctl register router public.localhost <password>
295 ejabberdctl register opensrf public.localhost <password>
296 ---------------------------------------------------------------------------
297
298 Update the OpenSRF configuration files
299 --------------------------------------
300
301 About the OpenSRF configuration files
302 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
303 There are several configuration files that you must update to make OpenSRF
304 work. SYSCONFDIR is `/opensrf/etc` by default, or the value that you passed to
305 `--sysconfdir` during the configuration phase.
306
307   * `SYSCONFDIR/opensrf.xml` - this file lists the services that this
308     OpenSRF installation supports; if you create a new OpenSRF service,
309     you need to add it to this file.
310       ** The `<hosts>` element at the bottom of the file lists the services
311          that should be started for each hostname. You can force the system
312          to use `localhost`, so in most cases you will leave this section
313          as-is.
314     
315   * `SYSCONFDIR/opensrf_core.xml` - this file lists the Jabber connection
316     information that will be used for the system, as well as determining
317     logging verbosity and defining which services will be exposed on the
318     HTTP gateway.
319
320   * `~/.srfsh.xml` - this file gives a Linux account the ability to use
321     the `srfsh` interpreter to communicate with OpenSRF services.
322
323 Updating the OpenSRF configuration files
324 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325   1. As the *opensrf* Linux account, copy the example configuration files
326      to create your locally customizable OpenSRF configuration files:
327 +
328 .Copying the example OpenSRF configuration files
329 [source, bash]
330 ---------------------------------------------------------------------------
331 cd SYSCONFDIR
332 cp opensrf_core.xml.example opensrf_core.xml
333 cp opensrf.xml.example opensrf.xml
334 ---------------------------------------------------------------------------
335 +
336   2. Edit the `SYSCONFDIR/opensrf_core.xml` file to update the four username
337      / password pairs to match the Jabber user accounts you just created:
338
339     a. `<config><opensrf>` = use the private Jabber `opensrf` user
340     b. `<config><gateway>` = use the public Jabber `opensrf` user
341     c. `<config><routers><router>` = use the public Jabber `router` user
342     d. `<config><routers><router>` = use the private Jabber `router` user
343   3. Create a `.srfsh.xml` file in the home directory of each user
344      that you want to use `srfsh` to communicate with OpenSRF services. For
345      example, to enable the *opensrf* Linux account to use `srfsh`:
346     a. `cp SYSCONFDIR/srfsh.xml.example ~/.srfsh.xml`
347     b. Open `~/.srfsh.xml` in your text editor of choice and update the
348        password to match the password you set for the Jabber `opensrf` user
349        at the `private.localhost` domain.
350
351 Starting and stopping OpenSRF services
352 --------------------------------------
353
354 To start all OpenSRF services with a hostname of `localhost`, issue the
355 following command as the *opensrf* Linux account:
356
357 [source, bash]
358 ---------------------------------------------------------------------------
359 osrf_control --localhost --start-all
360 ---------------------------------------------------------------------------
361
362 To stop all OpenSRF services with a hostname of `localhost`, issue the
363 following command as the *opensrf* Linux account:
364
365 [source, bash]
366 ---------------------------------------------------------------------------
367 osrf_control --localhost --stop-all
368 ---------------------------------------------------------------------------
369
370 Testing the default OpenSRF services
371 ------------------------------------
372
373 By default, OpenSRF ships with an `opensrf.math` service that performs basic
374 calculations involving two integers. Once you have started the OpenSRF
375 services, test the services as follows:
376
377 1. Start the `srfsh` interactive OpenSRF shell by issuing the following
378    command as the *opensrf* Linux account:
379 +
380 .Starting the `srfsh` interactive OpenSRF shell
381 [source, bash]
382 ---------------------------------------------------------------------------
383 srfsh
384 ---------------------------------------------------------------------------
385 +
386 2. Issue the following request to test the `opensrf.math` service:
387 +
388 [source, bash]
389 ---------------------------------------------------------------------------
390 srfsh# request opensrf.math add 2,2
391 ---------------------------------------------------------------------------
392 +
393 You should receive the value `4`.
394
395 Optional: Websockets installation instructions
396 ----------------------------------------------
397 Websockets are new to OpenSRF 2.4+ and are required for operating the new web-based
398 staff client for Evergreen.  Complete the following steps as the *root* Linux 
399 account:
400
401 1. Install git if not already present:
402 +
403 [source, bash]
404 ---------------------------------------------------------------------------
405 apt-get install git-core
406 ---------------------------------------------------------------------------
407 +
408 2. Install the apache-websocket module:
409 +
410 [source, bash]
411 ---------------------------------------------------------------------------
412 # Use a temporary directory
413 cd /tmp
414 git clone https://github.com/disconnect/apache-websocket
415 cd apache-websocket
416 apxs2 -i -a -c mod_websocket.c
417 ---------------------------------------------------------------------------
418 +
419 3. Create the websocket Apache instance (more information about this in 
420    `/usr/share/doc/apache2/README.multiple-instances`)
421 +
422 .(Debian / Ubuntu Precise)
423 [source, bash]
424 ---------------------------------------------------------------------------
425 sh /usr/share/doc/apache2.2-common/examples/setup-instance websockets
426 ---------------------------------------------------------------------------
427 +
428 .(Ubuntu Trusty)
429 [source, bash]
430 ---------------------------------------------------------------------------
431 sh /usr/share/doc/apache2/examples/setup-instance websockets
432 ---------------------------------------------------------------------------
433 +
434 4. Remove from the main apache instance
435 +
436 [source, bash]
437 ---------------------------------------------------------------------------
438 a2dismod websocket
439 ---------------------------------------------------------------------------
440 +
441 5. Copy into place the config files
442 +
443 .(Debian / Ubuntu Precise)
444 [source, bash]
445 ---------------------------------------------------------------------------
446 cp examples/apache2/websockets/apache2.conf /etc/apache2-websockets/
447 ---------------------------------------------------------------------------
448 +
449 .(Ubuntu Trusty)
450 [source, bash]
451 ---------------------------------------------------------------------------
452 cp examples/apache_24/websockets/apache2.conf /etc/apache2-websockets/
453 ---------------------------------------------------------------------------
454 +
455 6. OPTIONAL: add these configuration variables to `/etc/apache2-websockets/envvars`
456    and adjust as needed.
457 +
458 [source, bash]
459 ---------------------------------------------------------------------------
460 export OSRF_WEBSOCKET_IDLE_TIMEOUT=120
461 export OSRF_WEBSOCKET_IDLE_CHECK_INTERVAL=5
462 export OSRF_WEBSOCKET_CONFIG_FILE=/openils/conf/opensrf_core.xml
463 export OSRF_WEBSOCKET_CONFIG_CTXT=gateway
464 export OSRF_WEBSOCKET_MAX_REQUEST_WAIT_TIME=600
465 ---------------------------------------------------------------------------
466 +
467   * `IDLE_TIMEOUT` specifies how long we will allow a client to stay connected
468     while idle.  A longer timeout means less network traffic (from fewer
469     websocket CONNECT calls), but it also means more Apache processes are
470     tied up doing nothing.
471   * `IDLE_CHECK_INTERVAL` specifies how often we wake to check the idle status
472     of the connected client.
473   * `MAX_REQUEST_WAIT_TIME` is the maximum amount of time the gateway will
474     wait before declaring a client as idle when there is a long-running
475     outstanding request, yet no other activity is occurring.  This is
476     primarily a fail-safe to allow idle timeouts when one or more requests
477     died on the server, and thus no response was ever delivered to the gateway.
478   * `CONFIG_FILE / CTXT` are the standard opensrf core config options.
479
480 7. Before you can start websockets, you must install a valid SSL certificate 
481    in `/etc/apache2/ssl/`.  It is possible, but not recommended, to generate a 
482    self-signed SSL certificate.  For example, if you need to test with a self-signed 
483    certicate on Chrome or Chromimum browsers, one workaround is to start the browser 
484    with `--ignore-certificate-errors`.
485
486 8. After OpenSRF is up and running (or after any re-install),
487    fire up the secondary Apache instance. Errors will appear in
488    `/var/log/apache2-websockets/error.log`. Start apache2-websockets with:
489 +
490 [source, bash]
491 ---------------------------------------------------------------------------
492 /etc/init.d/apache2-websockets start
493 ---------------------------------------------------------------------------
494
495 Troubleshooting note for Python users
496 -------------------------------------
497
498 If you are running a Python client and trying to connect to OpenSRF running on
499 localhost rather than a hostname that can be resolved via DNS, you will
500 probably receive exceptions about `dns.resolver.NXDOMAIN`. If this happens,
501 you need to install the `dnsmasq` package, configure it to serve up a DNS
502 entry for localhost, and point your local DNS resolver to `dnsmasq`. For example,
503 on Ubuntu you can issue the following commands as the *root* Linux account:
504
505 .(Debian / Ubuntu) Installing and starting `dnsmasq`
506 [source, bash]
507 ---------------------------------------------------------------------------
508 aptitude install dnsmasq
509 /etc/init.d/dnsmasq restart
510 ---------------------------------------------------------------------------
511
512 Then edit `/etc/resolv.conf` and ensure that `nameserver 127.0.0.1` is the
513 first entry in the file.
514
515 Getting help
516 ------------
517
518 Need help installing or using OpenSRF? Join the mailing lists at
519 http://evergreen-ils.org/communicate/mailing-lists/ or contact us 
520 on the Freenode IRC network on the #evergreen channel.