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