Good advice in other answers about eating nutritionally with lots of vegetable and fruit fibers, and plenty of plain water.
Stay away from the junky refined and sugary foods for other reasons, but for constipation also.
Take a bit of vitamin C daily - our bodies do not produce it nor do we store it in our cells. It does loosen the stool, and one way to tell if you are intaking enough vitamin C is that it will cause a very soft stool when you reach just past your needed intake.
Also magnesium is about the best chronic constipation reliever -- that is why there are so many commercial laxative products using magnesium. Oral intake of magnesium is difficult to absorb sufficiently as needed without causing diarrhea but a daily capsule of it will help without any of the cramping or urgencies from laxative products. One of the most deficient minerals in the American populace is...magnesium. The required amount would change as diet, exercise, weather and other personal factors would indicate. Good luck learning!