San Francisco announced the deal on the first day of NFL free agency Tuesday, a day after signing wide receiver Randy Moss to give him a second chance.
The 25-year-old Cox didn't play in 2011, spending time with his family in Waco, Texas.
He was accused of sexually assaulting a woman at his apartment in September 2010 after a night of partying.
The former Broncos defensive back says he appreciates the opportunity.
General manager Trent Baalke says the team is "confident that Perrish will be a positive contributor to the 49ers, as well as our community."