But Sun, on the other hand, had a whole other set of problems. Apple is a consumer facing company. Sun is a business facing company. Sun's biggest competitor was Linux on any-brand PC server. That's a big challenge. So, they fought open source the only way they knew how... join them. If your biggest competitor is free running on commodity boxes, you have to go to that space. Unfortunately, there wasn't enough of a difference between Solaris and Linux to matter to most people, so they went with Linux. There is some great open source stuff in Solaris (ZFS, DTrace), but ultimately, there just wasn't enough 'there' there.
And then once you've lost the OS war, all that was left was hardware. Which, while high-quality, just wasn't enough to keep _all_ of Sun afloat. Perhaps though, it would have been enough to support the hardware divisions of Sun.
Similarly with Sun, it wasn't Sun verus the nebulous Linux. It was Sun versus the Linux ecosystem. You could argue too that one problem with Sun was that they sold hardware and software, and that you could get them separately.
And it looks like that turned out to be a superior strategy, in a profit-minded sort of way.