This is most likely due to having "Do Not Disturb" turned on. Do Not Disturb will disable all alerts when the phone is locked for the times it is scheduled to be on. Turn Do Not Disturb off by going to Settings -> Do Not Disturb -> slide to OFF.
When Do Not Disturb is enabled, calls and alerts that arrive while locked will be silenced, and a moon icon will appear in the status bar.
Also, turn off Do Not Disturb scheduling by going to Settings -> Do Not Disturb -> Schedule -> slide to OFF.
You may also want to check to make sure your Ringer and Alerts volume is turned up. To do so, go to Settings -> Sounds & Haptics -> then slide the Ringer and Alerts slider to the right to make the volume louder when you recieve a text message.