The Euro 2016 hosts twice surrendered the lead before Dimitri Payet's sublime free-kick in injury time at the end of the second half secured victory for Les Bleus.
Rami, who started alongside Laurent Koscielny at the heart of defence, lost striker Vincent Aboubakar for Cameroon's first goal just two minutes after Blaise Matuidi had put France ahead, and his failed attempt to win a header led to Eric Maxim Choupo-Moting scoring a second equaliser the 88th minute.
The Sevilla defender, who was called up to replace the injured Raphael Varane, concedes that he gave a nervy performance during the clash but insists it is better to produce such a display now, as opposed to during the finals.
"I thought I was timid. I know that I made mistakes. It's better to do it now than later," he told Canal Plus.
"I'm getting to know the group. It's been a super difficult week for me at the end of a long season.
"I'm calm in my head as, thanks to the team, we've won. It's a really positive point. Sometimes, I play big games and I lose. I learn from that and look at the bright side of things."
France face Scotland in their final pre-tournament friendly on Saturday.