If you're new to web development, then try checking out something like
Ning. Create your own social network for anything. They offer what you're looking for in a nutshell. These are suitable for smaller sized networks without much web dev skills needed.
now for more advanced...millions of users.
The real heavy sites like Facebook and MySpace were not made using any particular software... Code is code....As for maintenance, these require many many resources - Literally 100's of dedicated servers, all configured and interconnected...research cloud computing.