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