I assume when you say sunscreen you mean sunscreen lotion, as in putting on your skin. According to Wikipedia, the ingredients that actually block the UV radiation in sunscreen lotion are titanium dioxide and zinc oxide, and these metallic powders are mixed with a heavy oil to make a lotion that doesn't wash (or sweat) off easily.
Commercial lotions may also have some other organic chemicals that also block UV, but not to the same extent that titanium and zinc powder do.
Although the type of oil you mix into a home made recipe version is up to you, you will probably need to buy one or both titanium dioxide powder or zinc oxide powder to use if you plan on mixing your own. The only health risk of DIY sunscreen is inhaling the powders prior to mixing them in oil; this is not healthy for you but neither chemical is poisonous. One other disadvantage of homebrewed sunblock is you may end up looking like you are covered in white paste depending on how thick you smear it on yourself.
I checked Amazon for prices and food grade titanium dioxide powder runs about $20 a pound, and zinc oxide powder goes for half that.