So I had some trouble running the good old “sudo emerge mongodb -va” due to some issues. After installing it by hand I found this little portage overlay that handles things better, but it has an outdated version of MongoDB, so I’ll show you how to get the latest and greatest. It’s all very basic, but since I’m no sysadmin, I still had to wrestle with things a bit to get it working, so I hope to relieve others of the same effort.
Since the problem was with one of the dependencies (spidermonkey), you’ll need the static version, that is, the one that comes with all the dependencies compiled in. Below is the one I used, but make sure to find the latest tgz for your platform here (choose the “legacy-static”).
After that, basically all you have to do is follow the instructions on this guide. It’s in German, but you can get what you have to do from the commands it tells you to run (the automatic translation is also not so bad).
The only thing you’re not supposed to do is copy the script in the section “Start-Stop Script”. It is meant for Debian distributions and won’t work on Gentoo because of some missing commands. So instead, copy the script below into /etc/init.d/mongodb, give it +x permission and follow the rest of the guide as usual. Let me know if you run into any troubles!