There is no quick and easy way to silence all alerts in iOS while allowing the phone to ring. The alarm will always sound, even if the silent switch is activated (provided the phone is not powered off entirely).
Many people have asked for a 'bedside mode' similar to that offered by other smartphones. In this state, the alarm would still sound if set, and the phone would ring for incoming calls, but no other alerts will sound.
Though it can't be done in software settings, the equivalent can easily be acheived by plugging your headphones into the phone. The alarm and ringer will still sound through the phone speaker, but all other alerts will play only through the headphones.