]> git.evergreen-ils.org Git - OpenSRF.git/blob - README
update ChangeLog for 3.2.2
[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 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 Download and unpack the code
24 ----------------------------
25
26 Issue the following commands as the *user* Linux account.
27
28 1. Acquire a stable release tarball from https://evergreen-ils.org/opensrf-downloads/
29 +
30 [source, bash]
31 ------------------------------------------------------------------------------
32 wget https://evergreen-ils.org/downloads/opensrf-3.2.2.tar.gz
33 ------------------------------------------------------------------------------
34 +
35 [NOTE]
36 Developers can find the full source code at the OpenSRF Git repository:
37 http://git.evergreen-ils.org/?p=OpenSRF.git
38 +
39 2. Unpack the tarball, and move into that directory:
40 +
41 [source, bash]
42 ------------------------------------------------------------------------------
43 tar -xvf opensrf-3.2.2.tar.gz
44 cd opensrf-3.2.2/
45 ------------------------------------------------------------------------------
46
47 Installing prerequisites
48 ------------------------
49
50 OpenSRF has a number of prerequisite packages that must be installed
51 before you can successfully configure, compile, and install OpenSRF.
52 On Debian and Ubuntu, the easiest way to install these prerequisites
53 is to use the Makefile.install prerequisite installer.
54
55 Issue the following commands as the *root* Linux account to install 
56 prerequisites using the Makefile.install prerequisite installer, substituting 
57 your operating system identifier for <osname> below:
58
59 [source, bash]
60 ---------------------------------------------------------------------------
61 apt-get install make
62 make -f src/extras/Makefile.install <osname>
63 ---------------------------------------------------------------------------
64
65 Well-tested values for <osname> include:
66
67   * `debian-bullseye` for Debian 11
68   * `debian-buster` for Debian 10
69   * `debian-stretch` for Debian 9
70   * `ubuntu-bionic` for Ubuntu 18.04
71   * `ubuntu-focal` for Ubuntu 20.04
72
73 Patches and suggestions for improvement from users of these distributions,
74 or others, are welcome!
75
76 When the prerequisite installer reaches the Perl module stage, you may 
77 be prompted for configuration of Comprehensive Perl Archive Network (CPAN)
78 on your server. You can generally accept the defaults by pressing <return>
79 for all of the prompts, except for the country configuration.
80
81 Preamble: Developer instructions
82 --------------------------------
83
84 [NOTE]
85 Skip this section if you are using an official release tarball downloaded
86 from https://evergreen-ils.org/opensrf-downloads/
87
88 Developers working directly with the source code from the Git repository,
89 rather than an official release tarball, must install some extra packages
90 and perform one step before they can proceed with the `./configure` step.
91
92 As the *root* Linux account, install the following packages:
93
94   * autoconf
95   * automake
96   * libtool
97
98 As the *user* Linux account, issue the following command in the OpenSRF
99 source directory to generate the configure script and Makefiles:
100
101 [source, bash]
102 ------------------------------------------------------------------------------
103 autoreconf -i
104 ------------------------------------------------------------------------------
105
106 Configuration and compilation instructions
107 ------------------------------------------
108
109 Use the `configure` command to configure OpenSRF, and the `make` command to
110 build OpenSRF. The default installation prefix (PREFIX) for OpenSRF is
111 `/opensrf/`.
112
113 If you are building OpenSRF for Evergreen, issue the following commands as
114 the *user* Linux account to configure and build OpenSRF:
115
116 [source, bash]
117 ---------------------------------------------------------------------------
118 ./configure --prefix=/openils --sysconfdir=/openils/conf
119 make
120 ---------------------------------------------------------------------------
121
122 By default, OpenSRF includes C, Perl, and JavaScript support.
123 You can add the `--enable-python` option to the configure command
124 to build Python support and `--enable-java` for Java support.
125
126 If you are planning on proxying WebSockets traffic (see below), you
127 can add `--with-websockets-port=443` to specify that WebSockets traffic
128 will be going through port 443. Without that option, the default port
129 is 7682.
130
131 Installation instructions
132 -------------------------
133
134 1. Once you have configured and compiled OpenSRF, issue the following
135    command as the *root* Linux account to install OpenSRF:
136 +
137 [source, bash]
138 ---------------------------------------------------------------------------
139 make install
140 ---------------------------------------------------------------------------
141
142 Create and set up the opensrf Unix user environment
143 ---------------------------------------------------
144
145 This user is used to start and stop all OpenSRF processes, and must own all
146 files contained in the PREFIX directory hierarchy. Issue the following
147 commands as the *root* Linux account to create the `opensrf` user and set up
148 its environment, substituting <PREFIX> with the value you passed to `--prefix`
149 in your configure command:
150
151 .Creating the `opensrf` user
152 [source, bash]
153 ---------------------------------------------------------------------------
154 useradd -m -s /bin/bash opensrf
155 echo "export PATH=\$PATH:/<PREFIX>/bin" >> /home/opensrf/.bashrc
156 passwd opensrf
157 chown -R opensrf:opensrf /<PREFIX>
158 ---------------------------------------------------------------------------
159
160 Define your public and private OpenSRF domains
161 ----------------------------------------------
162
163 For security purposes, OpenSRF uses Jabber domains to separate services
164 into public and private realms. Throughout these instructions, we will use
165 the example domains `public.localhost` and `private.localhost`. 
166
167 On a single-server system, the easiest way to define public and private
168 domains is to define separate hostnames by adding entries to the `/etc/hosts`
169 file. Here are entries that you could add to a stock `/etc/hosts` file for our
170 example domains:
171
172 .Example added entries for `/etc/hosts`
173 [source, bash]
174 ---------------------------------------------------------------------------
175 127.0.1.2       public.localhost        public
176 127.0.1.3       private.localhost       private
177 ---------------------------------------------------------------------------
178
179 Adjust the system dynamic library path
180 --------------------------------------
181
182 Add `<PREFIX>/lib/` to the system's dynamic library path, and then run
183 `ldconfig` as the *root* Linux account.
184
185 On Debian and Ubuntu systems, run the following commands as the *root*
186 Linux account:
187
188 .Adjusting the system dynamic library path
189 [source, bash]
190 ---------------------------------------------------------------------------
191 echo <PREFIX>/lib > /etc/ld.so.conf.d/opensrf.conf
192 ldconfig
193 ---------------------------------------------------------------------------
194
195 On most other systems, you can add these entries to `/etc/ld.so.conf`, or
196 create a file within the `/etc/ld.so.conf.d/` directory, and then run
197 `ldconfig` as the *root* Linux account.
198
199 Configure the ejabberd server
200 -----------------------------
201
202 OpenSRF requires an XMPP (Jabber) server. For performance reasons, ejabberd is
203 the Jabber server of choice for the OpenSRF project. In most cases, you only
204 have to make a few changes to the default configuration file to make ejabberd
205 work for OpenSRF. 
206
207 1. Stop ejabberd before making any changes to its configuration by issuing the
208    following command as the *root* Linux account:
209 +
210 .Stopping ejabberd
211 [source, bash]
212 ---------------------------------------------------------------------------
213 systemctl stop ejabberd.service
214 ---------------------------------------------------------------------------
215 +
216 2. Edit the ejabberd config file.
217 +
218 (Debian Stretch) Ejabberd 16.x::
219 Open `/etc/ejabberd/ejabberd.yml` and make the following
220 changes:
221   a. Define your public and private domains in the `hosts` directive. For
222    example:
223 +
224 [source, bash]
225 ---------------------------------------------------------------------------
226 hosts:
227   - "localhost"
228   - "private.localhost"
229   - "public.localhost"
230 ---------------------------------------------------------------------------
231 +
232   b. Change `auth_password_format` to plain
233   c. Change `shaper:` `normal` and `fast` values to 500000
234   d. Increase the `max_user_sessions:` `all:` value to 10000
235   e. Comment out the `mod_offline` directive
236 +
237 -----------------------
238 ##mod_offline:
239     ##access_max_user_messages: max_user_offline_messages
240 -----------------------
241 +
242 (Debian Buster / Ubuntu Bionic / Ubuntu Focal) Ejabberd 18.x::
243 Open `/etc/ejabberd/ejabberd.yml` and make the following
244 changes:
245   a. Define your public and private domains in the `hosts` directive. For
246    example:
247 +
248 [source, bash]
249 ---------------------------------------------------------------------------
250 hosts:
251   - "localhost"
252   - "private.localhost"
253   - "public.localhost"
254 ---------------------------------------------------------------------------
255 +
256   b. Change `starttls_required` to false
257   c. Change `auth_password_format` to plain
258   d. Change `shaper:` `normal` and `fast` values to 500000
259   e. Increase the `max_user_sessions:` `all:` value to 10000
260   f. Comment out the `mod_offline` directive
261 +
262 -----------------------
263 ##mod_offline:
264     ##access_max_user_messages: max_user_offline_messages
265 -----------------------
266 +
267   g. Uncomment or add the `mod_legacy_auth` directive under the `modules:` section
268 +
269 -----------------------
270 mod_legacy_auth: {}
271 -----------------------
272 +
273 (Debian Bullseye) Ejabberd 21.x::
274 Open `/etc/ejabberd/ejabberd.yml` and make the following
275 changes:
276   a. Define your public and private domains in the `hosts` directive. For
277    example:
278 +
279 [source, bash]
280 ---------------------------------------------------------------------------
281 hosts:
282   - localhost
283   - private.localhost
284   - public.localhost
285 ---------------------------------------------------------------------------
286 +
287   b. Change `starttls_required` to false
288   c. Change `auth_password_format` to plain
289   d. Change all `shaper:` `normal` and `fast` values to 500000
290   e. Increase the `shaper_rules:` `max_user_sessions:` value to 10000
291   f. Comment out the `shaper_rules:` `max_user_offline_messages:` values
292 +
293 -----------------------
294 ##max_user_offline_messages:
295   ##5000: admin
296   ##100: all
297 -----------------------
298 +
299   g. Comment out the `mod_offline` directive
300 +
301 -----------------------
302 ##mod_offline:
303     ##access_max_user_messages: max_user_offline_messages
304 -----------------------
305 +
306   h. Add the `mod_legacy_auth` directive under the `modules:` section
307 +
308 -----------------------
309 mod_legacy_auth: {}
310 -----------------------
311 +
312 3. Restart the ejabberd server to make the changes take effect:
313 +
314 .Starting ejabberd
315 [source, bash]
316 ---------------------------------------------------------------------------
317 systemctl start ejabberd.service
318 ---------------------------------------------------------------------------
319
320 Create the OpenSRF Jabber users
321 -------------------------------
322
323 On each domain, you need two Jabber users to manage the OpenSRF communications:
324
325   * a `router` user, to whom all requests to connect to an OpenSRF service
326     will be routed; this Jabber user must be named `router`
327   * an `opensrf` user, which clients use to connect to OpenSRF services; this
328     user can be named anything you like
329
330 Create the Jabber users by issuing the following commands as the *root* Linux
331 account. Substitute `<password>` for your chosen passwords for each user
332 respectively:
333
334 .Creating the OpenSRF Jabber users
335 [source, bash]
336 ---------------------------------------------------------------------------
337 ejabberdctl register router private.localhost <password>
338 ejabberdctl register opensrf private.localhost <password>
339 ejabberdctl register router public.localhost <password>
340 ejabberdctl register opensrf public.localhost <password>
341 ---------------------------------------------------------------------------
342
343 Update the OpenSRF configuration files
344 --------------------------------------
345
346 About the OpenSRF configuration files
347 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
348 There are several configuration files that you must update to make OpenSRF
349 work. SYSCONFDIR is `/opensrf/etc` by default, or the value that you passed to
350 `--sysconfdir` during the configuration phase.
351
352   * `SYSCONFDIR/opensrf.xml` - this file lists the services that this
353     OpenSRF installation supports; if you create a new OpenSRF service,
354     you need to add it to this file.
355       ** The `<hosts>` element at the bottom of the file lists the services
356          that should be started for each hostname. You can force the system
357          to use `localhost`, so in most cases you will leave this section
358          as-is.
359     
360   * `SYSCONFDIR/opensrf_core.xml` - this file lists the Jabber connection
361     information that will be used for the system, as well as determining
362     logging verbosity and defining which services will be exposed on the
363     HTTP gateway.
364
365   * `~/.srfsh.xml` - this file gives a Linux account the ability to use
366     the `srfsh` interpreter to communicate with OpenSRF services.
367
368 Updating the OpenSRF configuration files
369 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
370   1. As the *opensrf* Linux account, copy the example configuration files
371      to create your locally customizable OpenSRF configuration files:
372 +
373 .Copying the example OpenSRF configuration files
374 [source, bash]
375 ---------------------------------------------------------------------------
376 cd SYSCONFDIR
377 cp opensrf_core.xml.example opensrf_core.xml
378 cp opensrf.xml.example opensrf.xml
379 ---------------------------------------------------------------------------
380 +
381   2. Edit the `SYSCONFDIR/opensrf_core.xml` file to update the four username
382      / password pairs to match the Jabber user accounts you just created:
383
384     a. `<config><opensrf>` = use the private Jabber `opensrf` user
385     b. `<config><gateway>` = use the public Jabber `opensrf` user
386     c. `<config><routers><router>` = use the public Jabber `router` user
387     d. `<config><routers><router>` = use the private Jabber `router` user
388   3. Create a `.srfsh.xml` file in the home directory of each user
389      that you want to use `srfsh` to communicate with OpenSRF services. For
390      example, to enable the *opensrf* Linux account to use `srfsh`:
391     a. `cp SYSCONFDIR/srfsh.xml.example ~/.srfsh.xml`
392     b. Open `~/.srfsh.xml` in your text editor of choice and update the
393        password to match the password you set for the Jabber `opensrf` user
394        at the `private.localhost` domain.
395
396 Starting and stopping OpenSRF services
397 --------------------------------------
398
399 To start all OpenSRF services with a hostname of `localhost`, issue the
400 following command as the *opensrf* Linux account:
401
402 [source, bash]
403 ---------------------------------------------------------------------------
404 osrf_control --localhost --start-all
405 ---------------------------------------------------------------------------
406
407 To stop all OpenSRF services with a hostname of `localhost`, issue the
408 following command as the *opensrf* Linux account:
409
410 [source, bash]
411 ---------------------------------------------------------------------------
412 osrf_control --localhost --stop-all
413 ---------------------------------------------------------------------------
414
415 Testing the default OpenSRF services
416 ------------------------------------
417
418 By default, OpenSRF ships with an `opensrf.math` service that performs basic
419 calculations involving two integers. Once you have started the OpenSRF
420 services, test the services as follows:
421
422 1. Start the `srfsh` interactive OpenSRF shell by issuing the following
423    command as the *opensrf* Linux account:
424 +
425 .Starting the `srfsh` interactive OpenSRF shell
426 [source, bash]
427 ---------------------------------------------------------------------------
428 srfsh
429 ---------------------------------------------------------------------------
430 +
431 2. Issue the following request to test the `opensrf.math` service:
432 +
433 [source, bash]
434 ---------------------------------------------------------------------------
435 srfsh# request opensrf.math add 2,2
436 ---------------------------------------------------------------------------
437 +
438 You should receive the value `4`.
439
440 Websockets installation instructions
441 ------------------------------------
442
443 1. Install websocketd (latest stable release from http://websocketd.com/)
444 +
445 .(Debian, Ubuntu)
446 [source,bash]
447 ---------------------------------------------------------------------------
448 cd /tmp
449 wget 'https://github.com/joewalnes/websocketd/releases/download/v0.3.0/websocketd-0.3.0-linux_amd64.zip'
450 unzip websocketd-0.3.0-linux_amd64.zip
451 sudo cp websocketd /usr/local/bin/
452 ---------------------------------------------------------------------------
453 +
454 2. Run websocketd
455 +
456 Choose option a or b, below.
457 +
458 [NOTE]
459 ===========================================================================
460 websocketd does not offer a configurable inactivity timeout, meaning
461 websocket client connections will persist until each client disconnects
462 or the service is restarted.  However, a timeout can be achieved with
463 the use of a proxy (option 'a' below).  A proxy also allows websocketd
464 to be exposed to web clients on port 443 instead of its internal port, 
465 which may simplify firewall configuration.
466 ===========================================================================
467 +
468 a. Run websocketd as 'opensrf'
469 +
470 [NOTE]
471 ===========================================================================
472 This choice requires one of the proxy configurations mentioned below.
473 ===========================================================================
474 +
475 .(Debian, Ubuntu)
476 [source,bash]
477 ---------------------------------------------------------------------------
478 /usr/local/bin/websocketd --port 7682 /openils/bin/osrf-websocket-stdio &
479
480 # Other useful command line parameters include:
481 # --loglevel debug|trace|access|info|error|fatal
482 # --maxforks <n>
483 # --sameorigin=true
484 # --origin=host[:port][,host[:port]...]
485
486 # See https://github.com/joewalnes/websocketd/blob/master/help.go
487 ---------------------------------------------------------------------------
488 +
489 b. Run websocketd without a proxy
490 +
491 .(Debian, Ubuntu)
492 [source,bash]
493 ---------------------------------------------------------------------------
494 sudo -b /usr/local/bin/websocketd --port 7682 --ssl --sslcert=/etc/apache2/ssl/server.crt \
495      --sslkey=/etc/apache2/ssl/server.key /openils/bin/osrf-websocket-stdio
496 ---------------------------------------------------------------------------
497
498 Optional: Using a web proxy (Apache 2.4 and above)
499 --------------------------------------------------
500 When the OpenSRF HTTP Translator runs behind a proxy, Apache must be 
501 configured to read the IP address of the originating client instead
502 of the proxy IP address.  
503
504 1. Enable mod_remoteip
505 +
506 [source,bash]
507 ---------------------------------------------------------------------------
508 sudo a2enmod remoteip
509 ---------------------------------------------------------------------------
510 +
511 2. Enable remote IP settings by uncommenting and modifying as needed the 
512    Apache configuration variables starting with RemoteIP* in the sample Apache
513    configuration file opensrf.conf.
514 +
515 3. Configure Apache to listen on port 7080 for HTTP and port 7443 for HTTPS
516    and ensure that it is not listening on ports 80 and 443, then restart Apache.
517 +
518 4. If you didn't run `configure` with the `--with-websockets-port=443` option,
519    edit `<PREFIX>/javascript/opensrf_ws.js` and `<PREFIX>/javascript/opensrf_ws_shared.js`
520    and change
521 +
522 [source, javascript]
523 ---------------------------------------------------------------------------
524 var WEBSOCKET_PORT_SSL = 7682;
525 ---------------------------------------------------------------------------
526 +
527 to
528 +
529 [source, javascript]
530 ---------------------------------------------------------------------------
531 var WEBSOCKET_PORT_SSL = 443;
532 ---------------------------------------------------------------------------
533
534
535 Optional: Using NGINX as a proxy
536 --------------------------------
537 NGINX can be used to proxy HTTP, HTTPS, and WebSockets traffic. Among other
538 reasons, this can be useful for Evergreen setups that want to have both
539 HTTPS and secure WebSockets traffic both go through port 443 while using
540 two Apache instances (one for the WebSockets gateway and one for the more
541 memory-intensive TPAC pages).
542
543 The following instructions are a guide for setting this up on Debian
544 and Ubuntu systems, but expect general familiarity with various system
545 administration and network tasks.  The steps should be run as the *root*
546 Linux account, and assume that you already followed the instructions
547 for installing WebSockets support.
548
549 1. Install NGINX if not already present:
550 +
551 [source, bash]
552 ---------------------------------------------------------------------------
553 apt-get install nginx
554 ---------------------------------------------------------------------------
555 +
556 2. Copy the example NGINX configuration file into place and remove default.
557 +
558 [source, bash]
559 ---------------------------------------------------------------------------
560 cd /path/to/opensrf-3.2.2
561 cp examples/nginx/osrf-ws-http-proxy /etc/nginx/sites-available/
562 ln -s /etc/nginx/sites-available/osrf-ws-http-proxy /etc/nginx/sites-enabled/osrf-ws-http-proxy
563 rm /etc/nginx/sites-enabled/default
564 ---------------------------------------------------------------------------
565 +
566 3. Edit `/etc/nginx/sites-available/osrf-ws-http-proxy` to set the location
567    of the SSL certificate and private key.
568 4. Generate a dhparam file in the directory specified in the nginx config.
569 +
570 [source, bash]
571 ---------------------------------------------------------------------------
572 # Default config stores dhparam.pem in the Apache2 ssl directory.
573 openssl dhparam -out /etc/apache2/ssl/dhparam.pem 2048
574 ---------------------------------------------------------------------------
575 +
576 5. Start NGINX
577 +
578 [source, bash]
579 ---------------------------------------------------------------------------
580 /etc/init.d/nginx start
581 ---------------------------------------------------------------------------
582
583 Optional: Using HAProxy as a proxy
584 ----------------------------------
585 HAProxy can also be used to proxy HTTP, HTTPS, and WebSockets traffic
586 as an alternative to NGINX.
587
588 The following instructions are a guide for setting this up on Debian
589 and Ubuntu systems, but expect general familiarity with various system
590 administration and network tasks.  The steps should be run as the *root*
591 Linux account, and assume that you already followed the instructions
592 for installing WebSockets support.
593
594 1. Install HAProxy if not already present:
595 +
596 [source, bash]
597 ---------------------------------------------------------------------------
598 apt-get install haproxy
599 ---------------------------------------------------------------------------
600 +
601 2. Append the example HAProxy to `haproxy.cfg`.
602 +
603 [source, bash]
604 ---------------------------------------------------------------------------
605 cd /path/to/opensrf-3.2.2
606 cat examples/haproxy/osrf-ws-http-proxy >> /etc/haproxy/haproxy.cfg
607 ---------------------------------------------------------------------------
608 +
609 3. Edit `/etc/haproxy/haproxy.cfg` to set the location
610    of the PEM file containing the SSL certificate and private key.
611 4. Start HAProxy.
612 +
613 [source, bash]
614 ---------------------------------------------------------------------------
615 /etc/init.d/haproxy start
616 ---------------------------------------------------------------------------
617
618 Troubleshooting note for Python users
619 -------------------------------------
620
621 If you are running a Python client and trying to connect to OpenSRF running on
622 localhost rather than a hostname that can be resolved via DNS, you will
623 probably receive exceptions about `dns.resolver.NXDOMAIN`. If this happens,
624 you need to install the `dnsmasq` package, configure it to serve up a DNS
625 entry for localhost, and point your local DNS resolver to `dnsmasq`. For example,
626 on Ubuntu you can issue the following commands as the *root* Linux account:
627
628 .Installing and starting `dnsmasq`
629 [source, bash]
630 ---------------------------------------------------------------------------
631 aptitude install dnsmasq
632 /etc/init.d/dnsmasq restart
633 ---------------------------------------------------------------------------
634
635 Then edit `/etc/resolv.conf` and ensure that `nameserver 127.0.0.1` is the
636 first entry in the file.
637
638 Getting help
639 ------------
640
641 Need help installing or using OpenSRF? Join the mailing lists at
642 http://evergreen-ils.org/communicate/mailing-lists/ or contact us 
643 on the Freenode IRC network on the #evergreen channel.