An oil refinery is an industrial plant where crude oil is processed and refined into useful petroleum products.
Raw or unprocessed oil (also referred to as "crude oil" or simply "crude") is not very useful in the form it comes out of the ground. It needs to be broken down into parts and refined before use in a solid material such as plastics and foams, or as petroleum fossil fuels as in the case of automobile and airplane engines.
Hydrocarbons are molecules of varying length and complexity made of hydrogen and carbon. Their various structures give them their differing properties and thereby uses. The trick in the oil refinement process is separating and purifying these. All these different hydrocarbons have different boiling points, which means they can be separated by distillation.
Once separated and any contaminents and impurities have been removed, the oil can be either sold without any further processing, or recombined to meet specific requirements (as in the case of fuels with different octane ratings) or even be reprocessed to break a heavy, long-chained oil into a lighter short-chained one.