docs: Remove out of date links to pserver.samba.org and old tarballs
[amitay/samba.git] / docs-xml / Samba3-HOWTO / TOSHARG-Compiling.xml
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3 <chapter id="compiling">
4 <chapterinfo>
5         &author.jelmer;
6         &author.jht;
7         &author.tridge;
8         
9         <pubdate> 22 May 2001 </pubdate>
10         <pubdate> 18 March 2003 </pubdate>
11         <pubdate> June 2005 </pubdate>
12 </chapterinfo>
13
14 <title>How to Compile Samba</title>
15
16 <para>
17 You can obtain the Samba source file from the
18 <ulink url="http://samba.org/">Samba Web site</ulink>. To obtain a development version, 
19 you can download Samba from Subversion or using <command>rsync</command>.
20 </para>
21
22 <sect1>
23 <title>Access Samba Source Code via GIT</title>
24
25
26 <sect2>
27 <title>Introduction</title>
28
29 <para>
30 <indexterm><primary>Subversion</primary></indexterm>
31 Samba is developed in an open environment. Developers use
32 GIT to <quote>checkin</quote> (also known as 
33 <quote>commit</quote>) new source code.  See the
34 <ulink noescape="1"
35        url="https://wiki.samba.org/index.php/Using_Git_for_Samba_Development">Using
36 Git for Samba Development page</ulink> in the Samba wiki.
37 </para>
38
39 </sect2>
40
41
42 </sect1>
43
44 <sect1>
45         <title>Accessing the Samba Sources via rsync and ftp</title>
46
47
48         <para>
49         <indexterm><primary>rsync</primary></indexterm>
50         <indexterm><primary>ftp</primary></indexterm>
51         <parameter>pserver.samba.org</parameter> also exports unpacked copies of most parts of the Subversion tree
52         at the Samba <ulink noescape="1" url="ftp://samba.org/pub/unpacked">unpacked</ulink> location and also
53         via anonymous rsync at the Samba <ulink noescape="1"
54         url="rsync://samba.org/ftp/unpacked/">rsync</ulink> server location.  I recommend using rsync rather
55         than ftp, because rsync is capable of compressing data streams, but it is also more useful than FTP because
56         during a partial update it will transfer only the data that is missing plus a small overhead.  See <ulink
57         noescape="1" url="http://rsync.samba.org/">the rsync home page</ulink> for more info on rsync.
58         </para>
59
60         <para>
61         The disadvantage of the unpacked trees is that they do not support automatic
62         merging of local changes as GIT does. <command>rsync</command> access is most convenient 
63         for an initial install.                      
64         </para>
65 </sect1>
66
67 <sect1>
68 <title>Verifying Samba's PGP Signature</title>
69
70 <para>
71 <indexterm><primary>GPG</primary></indexterm>
72 <indexterm><primary>PGP</primary></indexterm>
73 It is strongly recommended that you verify the PGP signature for any source file before
74 installing it. Even if you're not downloading from a mirror site, verifying PGP signatures
75 should be a standard reflex. Many people today use the GNU GPG tool set in place of PGP.
76 GPG can substitute for PGP.
77 </para>
78
79
80 <para>
81 With that said, go ahead and download the following files:
82 </para>
83
84 <para><screen>
85 &prompt;<userinput>wget http://samba.org/samba/ftp/samba-latest.tar.asc</userinput>
86 &prompt;<userinput>wget http://samba.org/samba/ftp/samba-latest.tar.gz</userinput>
87 &prompt;<userinput>wget http://samba.org/samba/ftp/samba-pubkey.asc</userinput>
88 </screen></para>
89
90
91 <para>
92 <indexterm><primary>PGP</primary></indexterm>
93 The first file is the PGP signature for the Samba source file; the other is the Samba public
94 PGP key itself. Import the public PGP key with:
95 <screen>
96 &prompt;<userinput>gpg --import samba-pubkey.asc</userinput>
97 </screen>
98 and verify the Samba source code integrity with:
99 <screen>
100 &prompt;<userinput>gzip -d samba-latest.tar.gz</userinput>
101 &prompt;<userinput>gpg --verify samba-latest.tar.asc</userinput>
102 </screen>
103 </para>
104
105 <para>
106 If you receive a message like, <quote>Good signature from Samba Distribution Verification Key...,</quote>
107 then all is well. The warnings about trust relationships can be ignored. An
108 example of what you would not want to see would be:
109 <screen>
110 gpg: BAD signature from <quote>Samba Distribution Verification Key</quote>
111 </screen>
112 </para>
113
114 </sect1>
115
116 <sect1>
117         <title>Building the Binaries</title>
118         
119         <para>
120         <indexterm><primary>autogen.sh</primary></indexterm>
121 <indexterm><primary>configure</primary></indexterm>
122         After the source tarball has been unpacked, the next step involves
123         configuration to match Samba to your operating system platform.
124         If your source directory does not contain the <command>configure</command> script,
125         it is necessary to build it before you can continue. Building of
126         the configure script requires the correct version of the autoconf
127         tool kit. Where the necessary version of autoconf is present,
128         the configure script can be generated by executing the following
129         (please note that in Samba 3.4.x, the directory is called source3 instead
130         of source):
131 <screen>
132 &rootprompt; cd samba-3.0.20/source
133 &rootprompt; ./autogen.sh
134 </screen>
135         </para>
136         
137
138         <para>
139         <indexterm><primary>configure</primary></indexterm>
140         To build the binaries, run the program <userinput>./configure
141         </userinput> in the source directory. This should automatically 
142         configure Samba for your operating system. If you have unusual 
143         needs, then you may wish to first run:
144 <screen>
145 &rootprompt;<userinput>./configure --help</userinput>
146 </screen>
147 </para>
148         
149         <para>
150         This will help you to see what special options can be enabled. Now execute
151         <userinput>./configure</userinput> with any arguments it might need:
152 <screen>
153 &rootprompt;<userinput>./configure <replaceable>[... arguments ...]</replaceable></userinput>
154 </screen>
155         </para>
156         
157         <para>
158         <indexterm><primary>make</primary></indexterm>
159         Execute the following create the binaries:
160 <screen>
161 &rootprompt; <userinput>make</userinput>
162 </screen>
163         Once it is successfully compiled, you can execute the command shown here to
164         install the binaries and manual pages:
165 <screen>
166 &rootprompt; <userinput>make install</userinput>
167 </screen>
168         </para>
169         
170         <para>
171         Some people prefer to install binary files and man pages separately. If this is
172         your wish, the binary files can be installed by executing:
173 <screen>
174 &rootprompt; <userinput>make installbin</userinput>
175 </screen>
176         The man pages can be installed using this command:
177 <screen>
178 &rootprompt; <userinput>make installman</userinput>
179 </screen>
180         </para>
181
182         <para>
183         Note that if you are upgrading from a previous version of Samba the old
184         versions of the binaries will be renamed with an <quote>.old</quote> extension.
185         You can go back to the previous version by executing:
186 <screen>
187 &rootprompt; <userinput>make revert</userinput>
188 </screen>
189         As you can see from this, building and installing Samba does not need to
190         result in disaster!
191         </para>
192         
193
194         <sect2>
195         <title>Compiling Samba with Active Directory Support</title>
196         
197         <para>
198         In order to compile Samba with ADS support, you need to have installed
199         on your system:
200         </para>
201
202         <itemizedlist>
203         
204             <listitem><para>
205                 The MIT or Heimdal Kerberos development libraries
206             (either install from the sources or use a package).
207                 </para></listitem>
208         
209             <listitem><para>
210                 The OpenLDAP development libraries.
211                 </para></listitem>
212             
213         </itemizedlist>
214
215         <para>
216         If your Kerberos libraries are in a nonstandard location, then
217         remember to add the configure option
218         <option>--with-krb5=<replaceable>DIR</replaceable></option>.
219         </para>
220
221         <para>
222         After you run configure, make sure that the 
223         <filename>include/config.h</filename> it generates contain lines like this:
224 <programlisting>
225 #define HAVE_KRB5 1
226 #define HAVE_LDAP 1
227 </programlisting>
228         </para>
229
230         <para>
231         If it does not, configure did not find your KRB5 libraries or
232         your LDAP libraries. Look in <filename>config.log</filename> to figure
233         out why and fix it.
234         </para>
235
236         <sect3>
237         <title>Installing the Required Packages for Debian</title>
238
239         <para>On Debian, you need to install the following packages:</para>
240         <para>
241                 <itemizedlist>
242                         <listitem><para>libkrb5-dev</para></listitem>
243                         <listitem><para>krb5-user</para></listitem>
244                 </itemizedlist>
245         </para>
246         </sect3>
247
248         <sect3>
249         <title>Installing the Required Packages for Red Hat Linux</title>
250
251         <para>On Red Hat Linux, this means you should have at least: </para>
252         <para>
253                 <itemizedlist>
254                         <listitem><para>krb5-workstation (for kinit)</para></listitem>
255                         <listitem><para>krb5-libs (for linking with)</para></listitem>
256                         <listitem><para>krb5-devel (because you are compiling from source)</para></listitem>
257                 </itemizedlist>
258         </para>
259
260         <para>in addition to the standard development environment.</para>
261
262         <para>If these files are not installed on your system, you should check the installation
263         CDs to find which has them and install the files using your tool of choice. If in doubt
264         about what tool to use, refer to the Red Hat Linux documentation.</para>
265
266         </sect3>
267
268         <sect3>
269         <title>SuSE Linux Package Requirements</title>
270
271         <para>
272         SuSE Linux installs Heimdal packages that may be required to allow you to build
273         binary packages. You should verify that the development libraries have been installed on
274         your system.
275         </para>
276
277         <para>
278         SuSE Linux Samba RPMs support Kerberos. Please refer to the documentation for
279         your SuSE Linux system for information regarding SuSE Linux specific configuration.
280         Additionally, SuSE is very active in the maintenance of Samba packages that provide
281         the maximum capabilities that are available. You should consider using SuSE-provided
282         packages where they are available.
283         </para>
284
285         </sect3>
286         
287         </sect2>
288                           
289 </sect1>
290
291 <sect1 id="startingSamba">
292         <title>Starting the &smbd; &nmbd; and &winbindd;</title>
293
294
295         <para>
296         <indexterm><primary>inetd</primary></indexterm>
297         You must choose to start &smbd;, &winbindd;  and &nmbd; either as daemons or from
298         <application>inetd</application>. Don't try to do both!  Either you can put
299         them in <filename> inetd.conf</filename> and have them started on demand by
300         <application>inetd</application> or <application>xinetd</application>, or you
301         can start them as daemons either from the command-line or in
302         <filename>/etc/rc.local</filename>. See the man pages for details on the
303         command line options. Take particular care to read the bit about what user
304         you need to have to start Samba. In many cases, you must be root.
305         </para>
306
307         <para>
308         The main advantage of starting &smbd; and &nmbd; using the recommended daemon method
309         is that they will respond slightly more quickly to an initial connection request.
310         </para>
311
312         <sect2>
313         <title>Starting from inetd.conf</title>
314
315         <indexterm><primary>inetd</primary></indexterm>
316         
317         <note>
318         <para>The following will be different if 
319         you use NIS, NIS+, or LDAP to distribute services maps.</para>
320         </note>
321         
322         <para>Look at your <filename>/etc/services</filename>. 
323         What is defined at port 139/tcp? If nothing is defined, 
324         then add a line like this:</para>
325
326         <para><programlisting>netbios-ssn     139/tcp</programlisting></para>
327
328         <para>Similarly for 137/udp, you should have an entry like:</para>
329
330         <para><programlisting>netbios-ns        137/udp</programlisting></para>
331
332         <para>
333         Next, edit your <filename>/etc/inetd.conf</filename> and add two lines like this:
334 <programlisting>
335 netbios-ssn stream tcp nowait root /usr/local/samba/sbin/smbd smbd 
336 netbios-ns dgram udp wait root /usr/local/samba/sbin/nmbd nmbd 
337 </programlisting>
338         </para>
339
340 <indexterm><primary>/etc/inetd.conf</primary></indexterm>
341         <para>
342         The exact syntax of <filename>/etc/inetd.conf</filename> 
343         varies between UNIXes. Look at the other entries in inetd.conf 
344         for a guide.
345         </para>
346
347         <para>
348         <indexterm><primary>xinetd</primary></indexterm>
349         Some distributions use xinetd instead of inetd. Consult the 
350         xinetd manual for configuration information.
351         </para>
352
353         <note><para>Some UNIXes already have entries like netbios_ns 
354         (note the underscore) in <filename>/etc/services</filename>. 
355         You must edit <filename>/etc/services</filename> or
356         <filename>/etc/inetd.conf</filename> to make them consistent.
357         </para></note>
358
359         <note><para>
360         <indexterm><primary>ifconfig</primary></indexterm>
361         On many systems you may need to use the
362         <smbconfoption name="interfaces"/> option in &smb.conf; to specify
363         the IP address and netmask of your interfaces. Run 
364         <application>ifconfig</application> as root if you do
365         not know what the broadcast is for your net. &nmbd; tries
366         to determine it at runtime, but fails on some UNIXes. 
367         </para></note>
368
369         <warning><para>
370         Many UNIXes only accept around five parameters on the command
371         line in <filename>inetd.conf</filename>.  This means you shouldn't
372         use spaces between the options and arguments, or you should use
373         a script and start the script from <command>inetd</command>.
374         </para></warning>
375
376         <para>
377         Restart <application>inetd</application>, perhaps just send it a HUP,
378         like this:
379 <indexterm><primary>killall</primary></indexterm>
380 <screen>
381 &rootprompt;<userinput>killall -HUP inetd</userinput>
382 </screen>
383         </para>
384                 
385         </sect2>
386         
387         <sect2>
388         <title>Alternative: Starting &smbd; as a Daemon</title>
389                 
390         <para>
391         <indexterm><primary>daemon</primary></indexterm>
392 <indexterm><primary>startsmb</primary></indexterm>
393         To start the server as a daemon, you should create a script something
394         like this one, perhaps calling it <filename>startsmb</filename>.
395         </para>
396
397 <para><programlisting>
398 #!/bin/sh
399 /usr/local/samba/sbin/smbd -D
400 /usr/local/samba/sbin/winbindd -D
401 /usr/local/samba/sbin/nmbd -D
402 </programlisting></para>
403
404         <para>
405         Make it executable with <command>chmod +x startsmb</command>.
406         </para>
407
408         <para>
409         You can then run <command>startsmb</command> by hand or execute
410         it from <filename>/etc/rc.local</filename>.
411         </para>
412
413         <para>
414         To kill it, send a kill signal to the processes &nmbd; and &smbd;.
415         </para>
416
417         <note><para>
418         If you use the SVR4-style init system, you may like to look at the
419         <filename>examples/svr4-startup</filename> script to make Samba fit
420         into that system.
421         </para></note>
422
423         <sect3>
424         <title>Starting Samba for Red Hat Linux</title>
425
426         <para>
427         Red Hat Linux has not always included all Samba components in the standard installation.
428         So versions of Red Hat Linux do not install the winbind utility, even though it is present
429         on the installation CDROM media. Check to see if the <command>winbindd</command> is present
430         on the system:
431 <screen>
432 &rootprompt; ls /usr/sbin/winbindd
433 /usr/sbin/winbindd
434 </screen>
435         This means that the appropriate RPM package was installed. The following response means
436         that it is not installed:
437 <screen>
438 /bin/ls: /usr/sbin/winbind: No such file or directory
439 </screen>
440         In this case, it should be installed if you intend to use <command>winbindd</command>. Search
441         the CDROM installation media for the samba-winbind RPM and install it following Red Hat
442         guidelines.
443         </para>
444
445         <para>
446         The process for starting Samba will now be outlined. Be sure to configure Samba's &smb.conf;
447         file before starting Samba. When configured, start Samba by executing:
448 <screen>
449 &rootprompt; service smb start
450 &rootprompt; service winbind start
451 </screen>
452         These steps will start &nmbd;, &smbd; and &winbindd;.
453         </para>
454
455         <para>
456         To ensure that these services will be automatically restarted when the system is rebooted
457         execute:
458 <screen>
459 &rootprompt; chkconfig smb on
460 &rootprompt; chkconfig winbind on
461 </screen>
462         Samba will be started automatically at every system reboot.
463         </para>
464
465         </sect3>
466
467         <sect3>
468         <title>Starting Samba for Novell SUSE Linux</title>
469
470         <para>
471         Novell SUSE Linux products automatically install all essential Samba components in a default installation.
472         Configure your &smb.conf; file, then execute the following to start Samba:
473 <screen>
474 &rootprompt; rcnmb start
475 &rootprompt; rcsmb start
476 &rootprompt; rcwinbind start
477 </screen>
478         Now execute these commands so that Samba will be started automatically following a system
479         reboot:
480 <screen>
481 &rootprompt; chkconfig nmb on
482 &rootprompt; chkconfig smb on
483 &rootprompt; chkconfig winbind on
484 </screen>
485         The Samba services will now be started automatically following a system reboot.
486         </para>
487
488         </sect3>
489
490         </sect2>
491
492 </sect1>
493
494 </chapter>