Build Samba from Source
- 1 Introduction
- 2 Samba operating system requirements
- 3 Obtaining Samba
- 4 Extracting the source package
- 5 configure
- 6 make
- 7 make test (optional)
- 8 make install
- 9 Upgrading a source version
- 10 Additional information
Usually most users run packages shipped with their distribution or created by 3rd parties, like SerNet (Enterprise/Samba+), there are those out there, who want/need to compile Samba themselves. Common reasons are that the packages shipped with the distribution are old or not available for your platform, or you have reported a bug and got a patch from a developer to test, before it is included in the next official release. There are many reasons why users compile Samba. This documentation should still users fears about compiling Samba. Basically it's done with a few steps:
- Install all dependencies (e. g. libraries) via the package manager of your distribution
- Download the sources from samba.org
- Extract the source package
- make install
Even if there are a few more things to mention and to know, you will see that compiling Samba is no sorcery. ;-)
The following is suitable for any kind of Samba installation: Samba Active Directory Domain Controller, Member Server (AD + NT4 domain), Samba NT4 PDC, etc.
Samba operating system requirements
Samba requires libraries and other software to compile and run. The first task is to install all these requirements.
Stable version (recommended)
Download the latest version of Samba from https://www.samba.org/. It is always recommended to install the latest version of the current stable release. If you need to use a previous series, always choose the last version from the maintainance mode series or at least from the security-fixes-only mode. Older versions may not contain all improvements, bug and security fixes. If you ask for help, e. g. on the Samba Mailing List, you will typically be told to try a recent version, to ensure that you didn't hit a bug, that has been fixed in the meantime. Further information about the Samba release planning and supported release lifetime, can be found on the Samba release planning page.
$ wget https://download.samba.org/pub/samba/stable/samba-x.y.z.tar.gz
Not recommended for production usage!
Extracting the source package
Extract the downloaded source package into the current directory:
$ tar -zxf samba-x.y.z.tar.gz
Step into the directory with the extracted sources:
$ cd samba-x.y.z/
Here you need to run the "configure" script. Its main purpose is to create a "Makefile", that is used by "make" for compilation, but it also allows you to set various parameters, like paths where the binaries should be installed. If you don't want to customize any paths or enable/disable parts of Samba that should be build, it's sufficient to run the command without any options:
If anything fails - usually because of missing dependencies - read the error message and fix the problem. The following example error indicates, that the GnuTLS headers are are not found:
Checking for gnutls >= 1.4.0 and broken versions : not found /usr/src/samba-x.y.z/source4/lib/tls/wscript:37: error: Building the AD DC requires GnuTLS (eg libgnutls-dev, gnutls-devel) for ldaps:// support and for the BackupKey protocol
If all checks are done and nothing is missing, "configure" finishes with an appropriate message:
'configure' finished successfully (1m2.432s)
In this case, continue with the next step: make
Customizing configure options
Even if running "./configure" without any options is sufficient, you may want to adapt some of the paths or enable/disable features. For that, first make yourself familiar with the list of possible options:
$ ./configure --help
The output is quite long, but there are mainly two important parts of options:
There are many "--enable-*/--disable-*", as well as "--with-*/--without-*" options. They allow you to turn on features that should be build, and to turn off for those that shouldn't. Each of the options can be turned to its opposite, by switching "enable" to "disable" and "with" to "without" and vice versa. Here are some examples:
- Example 1: Disable CUPS support (enabled by default):
--enable-cups Build with cups support (default=yes)
- If you don't require support for CUPS, you can disable it by adding "--disable-cups" to the configure command:
$ ./configure ..... --disable-cups
- Example 2: Compile Samba without Active Directory Domain Controller capabilities:
--without-ad-dc disable AD DC functionality (enables Samba 4 client and Samba 3 code base).
- If you build Samba for a host that shouldn't be an AD DC, you can disable this function, by adding "--without-ad-dc" to the configure command:
$ ./configure ..... --without-ad-dc
- Example 3: Build with debug information, that may help to diagnose in case of failure:
$ ./configure ..... --enable-debug
Warning: Don't enable/disable features unless you know what you're doing! Changing options may prevent your Samba installation from working as expected!
By default, your whole Samba installation, including databases, smb.conf, etc., will be in /usr/local/samba/ (value of "--prefix="). This is good if you want to keep everything in one place, but you can also change some paths. Here are some examples:
- Install daemon binaries (smbd, samba, etc.) in /sbin/ instead of /usr/local/samba/sbin/
# ./configure ..... --with-sbindir=/sbin/
- Set the default path for smb.conf to /etc/samba/ instead of /usr/local/samba/etc/
# ./configure ..... --with-sysconfdir=/etc/samba/
- Place the Samba man pages into a directory that is part of the systems manpath
# ./configure ..... --mandir=/usr/share/man/
The next step is quite simple. To start the compile process, run
Depending of your number of CPU cores, you can run multiple jobs parallel (2 in the following example):
$ make -j 2
If everything is successfully compiled, "make" finishes with an appropriate message:
Waf: Leaving directory `/usr/src/samba-x.y.z/bin' 'build' finished successfully (9m3.667s)
In this case, continue with the next step: make install
make test (optional)
This step is optional and usually only interesting for developers.
# make test
runs the Samba selftest suite. It requires that Samba was built with --enable-selftest.
The last step - the installation - needs to be run as "root", to allow writing to the destination directories and setting permissions.
# make install
If everything is successfully installed, "make install" finishes with an appropriate message:
Waf: Leaving directory `/usr/src/samba-x.y.z/bin' 'install' finished successfully (18.243s)
Upgrading a source version
The steps are the same as for a new installation. For further information, see Updating Samba.
Viewing build options of existing installations
If you already have Samba installed and want to see, what options were used at build time, run the following command:
$ smbd -b