Build for Linux

Binaries are available for most platforms. Most users do not need to compile MongoDB themselves. In addition, every prebuilt binary has been regression tested. See the Downloads page for prebuilt binaries.

Build MongoDB version 2.1.1 or Later

These build instructions apply to the MongoDB git master branch (https://github.com/mongodb/mongo) and to versions 2.1.1 and onward.


You must have the following:

  • SCons (See SCons and MongoDB for more information about the MongoDB SCons deployment.)
  • The gnu C++ toolchain
  • glibc-devel
  • git, in order to get the code from GitHub

To install the above on Fedora, issue the following:

sudo yum install git scons gcc-c++ glibc-devel

To install the above on Ubuntu, issue the following:

sudo apt-get install git-core build-essential scons libssl-dev

If you are building MongoDB with SSL support you also need to install the libssl headers.

For Fedora:

sudo yum install openssl-devel

For Ubuntu:

sudo apt-get install libssl-dev


  1. Install any needed prerequisites (see above).

  2. Get the source code:

    git clone git://github.com/mongodb/mongo.git
    cd mongo
  3. Pick a version to build (only use “master” if you are doing development work).

    1. List all tagged versions:

      git tag -l
    2. Check out a tagged release, e.g. 2.4.0:

      git checkout r2.4.0
    3. Compile:

      scons all

      If you want to build MongoDB with SSL support, add the --ssl option to scons, as in the following:

      scons --ssl all

      See the Connect to MongoDB with SSL tutorial for more information on SSL and MongoDB.

    4. Install. Use --prefix to specify where you want to install your binaries. The default is /usr/local.

      scons --prefix=/opt/mongo install


  • Link errors. If link errors occur, the -t gcc option is useful for troubleshooting. Try adding -t to the SConstruct file’s LINKFLAGS.

  • Undeclared FIPS_mode_set error. Building MongoDB with SSL support requires an OpenSSL version that defines FIPS_mode_set, such as OpenSSL 1.0.1e. The use of OpenSSL versions that do not define FIPS_mode_set returns the following error during the build:

    'FIPS_mode_set' was not declared in this scope

    Specify the appropriate OpenSSL with the --extrapath option, as in the following example:

    scons --extrapath /usr/local/openssl/1.0.1e --ssl all