You can do both.
I will take our example at OAuth.io, we have built an open source daemon for OAuth that solve a problem for developers and we made a startup to sell the service on top.
Look what Docker is becoming. Being a startup and contributing to open source are not opposite.
Or you can see even Github that contribute to open source by making a startup to help everybody contribute on open source...
Or Twitter with Bootstrap etc....