But the answer is not to simple. Question is whether you want to code one or you want pre-packed software package.
But if you want software to do so. Then there are many options:
1. Ning (open source and simple but few options)
2. Drupal.org (again free with nicely packed features)
3. Dolphin (used to be open source once but you can download previous version)
4. Elgg (free + very few options are available but ok for begginers)
5. Xoops (free + nice set of options difficult to configure)
This list is endless....