The first factor is temperature. You need to store butter at 40°F or lower, because high temperature will make its fat melt and eventually spoil. Also, keep an eye on the light! You need to keep your butter away from direct light, and a dark, dry place will be a better choice. If you want to make your butter last longer, store it in a sealed airtight container in the freezer.