Health insurance

How do I get local Spanish health insurance.

By either paying into "the system" or purchasing an insurance.
What you do depends on what you are doing/going to do in Spain.
To be honest your post lacks  information.
Please give us details of what you are planning or doing, some details of your past etc.
It is not being nosy just all this and more can influence how you can obtain medical cover. And which way maybe the easiest or cheapest for you.

Oh and a thank you, in advance for your answer to my question.

Thank you for your help despite the limited info I furnished. I am 50 retired and want to rent a housc and then apply for residency. I guess my question should first deal with obtaining residency first?

If you are not an EU citizen (and from your profile it suggests you are not) then you will needed a visa.
Here is what the Spanish embassy in Washington  has to say on this matter.
http://www.exteriores.gob.es/Consulados … Visas.aspx

Scroll down until you find the correct visa you are wanting to apply for.
You cannot apply for a visa to live in Spain whilst you are in Spain.
Hope that helps.