I always wondered but nothing came to mind, all the cannons i've seen on age of sail warships are on wheels so when they are fired, it would make sense the recoil pushes them back.I'm guessing this isnt the case because then the cannons could just roll around the ship if it was in an awkward angle.Then i thought maybe they were tied around the gunports but then the recoil could potentionally break some of the boards.Please explain this i can't live without knowing it.
The guns (cannons) were placed in wooden carriages also called trucks. Attached to the trucks were typically at least three sets of block and tackle systems, one on each side and one to the inboard or rear of the truck. The side tackles were secured to the bulkhead or bulwark (wall) of the ship and the one on the inboard side of the gun was secured to the deck. An additional large rope or hawser called breeching was connected from the bulwark , through rings on the side of the carriage and around the breech of the gun. The three point system of pulleys kept the gun secured and from rolling around on the deck as the ship was moving.
During use, the tackles were used to pull the gun through the gun port prior to being fired. Once fired, the pulleys, along with the breeching hawser stopped the recoil and held the gun in place to be reloaded. By using the side tackles, along with brute force, the guns could be aimed from side to side. a wedge shaped device called a quoin was placed at the breech end of the gun to adjust the elevation (up and down).
An excellent diagram and description of what it took to load and fire these guns can be found on page 8 of The Constitution Gun Deck at this link