On iPhone, how do you back up only contacts not photos without paying for the iCloud subscription?
Assuming you are talking about backing up through iCloud, you can exclude the data of specific apps from a backup; the Apple Support article “Manage Your iCloud Storage” explains this in more detail. I am not entirely sure, but I believe you can also exclude the photo library from this list as well, assuming you are not using iCloud Photo Library. Most apps don’t put that much data in a backup, so you should be able to stay within the limits of the free 5 GB iCloud subscription by excluding the few exceptions.

Another option is to not use iCloud for backup at all, as explained in the article “How to back up your iPhone, iPad, and iPod touch”, you can make a backup on a Mac or Windows PC through iTunes.