Exercise regularly, that also helps to keep things moving. Try not to strain, you are more likely to get hemmorhoids/piles that way.
If you still have problems, try fibre supplements like metamucil or benefiber, but remember if you take these you must drink more water, or your constipation may get worse. These supplements draw water into the gut, so you have to increase your fluid intake.
If you still can't pass, have blood in the stool or abdominal pains, please see your doctor.
Love yourself, take care of your health!