Build Samba from Source
Samba OS Requirements
Because of the constantly changing and ever expanding nature of Linux, the Samba AD DC OS requirements page is now self contained. This page not only includes the required packages for a successful Samba AD DC deployment, but also the required file system features. Please consider that page as a prerequisite to a successful Samba AD DC setup.
Step 1: Download Samba
Currently, there are two methods to download the current Samba sources, either as a tarball of the latest stable release, or a development version via git. If you hope to work with the team on a development version to resolve issues you may hit via code changes, we recommend using the git method for downloading Samba, as it makes getting updates easier, and also allows you to integrate test patches from Samba developers more easily in case of problems.
In the following examples we will assume that your top-level source is named samba-master, samba-v4-0-stable, or samba-v4-0-test depending on which head you're downloading from. If you downloaded a tarball this will instead be based on the name of the tarball downloaded (e.g. samba-4.0.0 for the tarball samba-4.0.0.tar.gz). Also note that in the master branch the Samba 4 code in our current git tree is now located in the top level directory.
Downloading a tarball
If you wish to use a released version of Samba 4.0, you can download the latest Samba 4.0 tarball from the Samba website
Downloading via git
Git allows you to download the source tree via either the git or http protocols. In general, the git protocol is the preferred choice since it compresses the data being transferred. To download the source tree via git, run the following command:
$ git clone git://git.samba.org/samba.git samba-master
Alternatively, if you prefer to use the http protocol, run the following command:
$ git clone http://gitweb.samba.org/samba.git samba-master
Either command will create a directory called samba-master in the current directory. This holds a checkout of the 'master' development branch.
If you are using the checkout for a production installation you should use the following git branches:
- 'v4-0-stable' (which contains the latest stable 4.0.x release)
$ git clone -b v4-0-stable git://git.samba.org/samba.git samba-v4-0-stable
- 'v4-0-test' (which contains the patches scheduled for the next stable 4.0.x release)
$ git clone -b v4-0-test git://git.samba.org/samba.git samba-v4-0-test
Updating via git
If you already have downloaded the source tree via git and want to update the tree to the latest version, run the following command in your samba-master directory:
$ git pull
If you get an error like this:
fatal: Unable to create '[...]/samba_master/.git/index.lock': File exists.
Run the command below to reset your tree.
If you are having trouble compiling the source, it may be due to stale files. You can reset your git tree to correct these errors. To reset your git tree, run the following command in your samba-master directory:
$ git clean -x -f -d
Step 2: Compile Samba
To build Samba, run the following command in your samba-master directory:
$ cd samba-master $ ./configure $ make
The above command will setup Samba to install in /usr/local/samba.
- If you want Samba to install in a different directory, then you should use the --prefix option to configure.
- We recommend using --enable-debug --enable-selftest for Samba is that it will include extra debug information that will help us diagnose problems in case of failures, and will also allow you to run our selftest make test to validate that Samba can behave correctly on your platform. Both of these are however, entirely optional.
Step 3: Install Samba
To install Samba, run the following command in your samba-master directory:
$ make install
Note that this must be run as a user who has permission to write to the install directory, which defaults to /usr/local/samba. See Step 2: Compile Samba for instructions on how to change the install directory.
Upgrading a source version
To upgrade to the latest Samba version from a previous Samba release, you must first download the latest tarball, or use the git tree. If using git, you may either do a full download of the latest git tree as described in the Downloading via git section, or you may upgrade your current git tree as described in the Updating via git section. Once you have obtained the latest version, simply run the following commands.
$ cd samba-master $ ./configure $ make $ make install
- Note: Please use the same ./configure options as before to retain full functionality.
For more information on the commands above and their associated options, please refer to Step 2