Once again, we can blame Latin for a curious term. In English, "Rx" doesn’t seem to have any connection to "pharmacy." However it does in Latin, albeit in a roundabout way.
Doctors write Rx in the heading of prescriptions as an instruction to "take" the medicine. The pharmacists filling the orders understand this shorthand (and hopefully they can read the doctors’ handwriting) and print it on pill bottles with whatever else doctors order, such as "take twice daily with food." Somewhere along the line, pharmacists started using "Rx" on their storefront signs so patients knew where to get their doctors’ instructions translated.