a photon has energy, which is equivalent to mass, and therefore interacts via gravity with everything else. https://van.physics.illinois.edu/qa/listing.php?id=16351
Light has no mass. It always follows the shortest path between two points - but around very massive objects that path is not a 'common-sense' straight line.
As for having energy but no mass, well, does a ripple on a pond have mass? It's just the same stuff as the rest of the pond, but it is somehow excited, and travels at a given speed. Light's (almost) the same thing. There is energy by virtue of its motion, but no *thing* is moving.