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