OK, so you have decided that you'd like to stock up but you don't have a lot of space and you don't have the money to go and buy the store out. I'll tell you how I did it over time. Please do not beat yourself up if your circumstances are different. I know that some people have marginal housing and/or very little resources or space for storage (or freezer space)--other circumstances can also make this a hassle or not very doable. If you've managed to get around those obstacles, I'd love to hear about it because honestly, I don't know what I would do. (Unlike some PF bloggers, I'm not good at the "you should just" advice. I'm good at the "this is what I did/what worked for you?" thing.)
First, I didn't fill my pantry shelves overnight, or even over the course of a month or two. It took a while. So please don't think that you need a lot of extra cash to do this and that it has to be done ASAP. You don't and it doesn't, double-pinky swear.
Basically, I watch the sales. If things that I like to eat and that I use go on sale, I buy as many as I can (within reason--if I can afford a hundred of them, I won't get that many. First, it's rude to the other customers and second, even though I have a couple of pantry areas I just don't have that kind of room). I don't aim to get everything I need, just the things that go on sale or that are at a very good price. So, for example, a few months ago the store near me had 28-oz. cans of tomatoes (diced, crushed, whole, you name it) on sale for 44 cents. I have never seen the prices that low--they are often on sale for 10 for $10. So I got about 30 of various kinds. If cheese goes on sale or I find a very good price, I'll buy it. If it's a block of cheese, I'll shred it at home, put it in a freezer bag, and freeze it. It's ready to use whenever I need it for cooking. (If I keep blocks of sharp cheddar in the fridge, they don't last the day so I tend to shred and freeze what I buy and use it for things like chili or tacos or omelettes or other things. Eventually, my pantry and freezer are fully stocked.
Another thing I do is use up everything I have and turn it into something else. If I make a roast chicken, I take the bones and make stock and either can it or freeze it. I make vegetable stock from the ends and peelings of fresh vegetables and herbs I have. I'll freeze my leftovers or turn them into something else to eat later and freeze it (soup, casserole, sauce, etc.). Stretch your supplies and you don't need to replenish them.
I don't go hog wild--with the exception of the 45 cent cans of tomatoes, I usually get enough to last me until the next sale.
I have a second bedroom and no roommates, so I have a set of metal wire shelves set up in my second bedroom for my pantry/canning supplies area. I also have a pantry cabinet in my kitchen. I keep a deep freeze in my second bedroom as well. If I had a roommate, I'd re-purpose the linen closets as a pantry--you can keep towels and sheets in storage boxes under the bed. Look for space that is not used and that is reasonably accessible (if it's a pain to get to, you'll never use the stuff).
As I said, I don't go overbard, jokes my friends make about my being ready for the apocalypse not withstanding. (I'm not ready for the apocalypse. I'm ready for last-minute dinner parties and the odd nor'easter.) I eat what I stock up on (don't hoard--even canned goods will go off and not taste that good if you keep them for too long) and I stock up gradually when things go on sale or when I get a bunch of things from the CSA, from my garden (ha! right) or a friend or relative's garden.