I am not sure in which version of iOS you want to take the backup of text messages in your iPhone, here is the solution for only iOS 11.3 and former version. Follow the steps below to find the solution:
Step 1: Connect your phone to a Wi-Fi connection.
Step 2: Now, go to the settings and click on iCloud.
Step 3: Now, Scroll down and click ‘backup’ or ‘iCloud backup’. Then click on Back Up Now to backup text messages on iPhone to iCloud.