In fact, sunlight exposure is very important for other crucial mechanisms in our body like melatonin regulation and D vitamin production.
You still can have all the benefits and fun by simply being more active in morning and sunset, avoiding midday exposure (which is already part of the culture in many sunny regions), and wearing the sunscreen and proper clothing to protect your skin. Of course, how much UV exposure do you need for you body to function normally and not let sun ruin your skin depends primarily on where you live, is it summer or winter, etc. It all comes down to limiting how much UV radiation you'll get. If you're dark skinned it also helps - the melanin in your skin acts as an additional layer of protection against UV rays.
source: married to a dermatologist.
I'm getting a bit jaded with vitamin D and UV studies and it's possible that one will come along and prove me wrong, but thus far they've generated a lot of hype but failed when experimentally tested.
depending on where you are in the world, sunblock might be enough to keep you on the good side, elsewhere (e.g. Australia) there are elaborate cultural rituals to reduce radiation exposure to safe levels (https://en.wikipedia.org/wiki/Slip-Slop-Slap).