- Contribute to the MongoDB Project >
- Build for Linux
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
- 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.
sudo yum install openssl-devel
sudo apt-get install libssl-dev
Install any needed prerequisites (see above).
Get the source code:
git clone git://github.com/mongodb/mongo.git cd mongo
Pick a version to build (only use “master” if you are doing development work).
List all tagged versions:
git tag -l
Check out a tagged release, e.g. 2.4.0:
git checkout r2.4.0
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.
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