I was in the same boat, it takes some time but it's possible to gain without gaining too much fat.
If it's safe for you, you can try to count calories. Calculate your tdee online and put it into an app like my fitness pal.
Food wise you can eat pretty much anything in moderation, just try to stay away from too much junk food. Also weight gain shakes are pretty good.
You can find online a lot of beginner programs, you just have to google it.