The first-place Dodgers won three of the four games against the Cardinals at Busch Stadium, and the Dodgers are now 17-3 since the All-Star break after a 7-1 trip to Chicago and St. Louis.
Ellis' homer, his sixth of the season, came in the fifth inning off the Cardinals' Carlos Martinez, a right-hander making his first start in the majors.
But moments after Ellis' hit, Martinez developed cramping in his throwing hand and had to leave the game.
It was the second time in as many nights that the St. Louis starting pitcher was forced from the game with an injury.
Martinez had been called up from triple-A Memphis to make the start in place of veteran Jake Westbrook. That's because Westbrook was pressed into duty Wednesday when Cardinals' starter Shelby Miller was struck by Carl Crawford's line drive in the first inning.
Ryu gave up the one run, which was unearned, on five hits while striking out seven Cardinals in his seven innings of work. He did not walk a batter.
Crawford scored the Dodgers' first run on a sacrifice fly by Adrian Gonzalez.
St. Louis tied the score, 1-1, in the fourth inning on a lapse by Dodgers center fielder Andre Ethier.
After Matt Holliday singled, David Freese hit a single that Ethier first bobbled and then lobbed over the head of second baseman Mark Ellis. The ball hit the second-base bag and bounced away, allowing Holliday to score. Ethier was given an error on the play.
Jerry Hairston Jr. had a pinch-hit single to score the Dodgers' fifth run in the eighth inning.
The Dodgers return home to face the Tampa Bay Rays on Friday night at Dodger Stadium.