Ankiel launched a pinch-hit three-run shot for the majors' first homer this season, Bud Norris pitched well for the win and Erik Bedard threw 31⁄3 scoreless innings for his first career save.
Having switched from the National League to the AL in the offseason, the Astros earned their first opening day victory since 2006 and the 4,000th regular-season win in franchise history.
The Astros are coming off consecutive 100-loss seasons and have the lowest payroll in the majors, prompting many to predict they will be the worst team in the majors.
But Houston opened in style wearing uniforms that brought back the orange and blue of old-school Astros teams.
After the game, rapper Drake's rags-to-riches hit "Started from the Bottom" played on a loop in the clubhouse. Houston, which has finished last in the majors each of the last two seasons, decided the song would be its postgame music after wins this season.
Justin Maxwell added a pair of triples and made a nifty catch in center field.
Norris (1-0) allowed five hits and two runs with five strikeouts in 52⁄3 innings. He was one of five Astros making their first opening day start on baseball's second-youngest team.
"To sit at 1-0 right now feels pretty darn good, and we've just got to go back out there on Tuesday and play some more baseball," Norris said. Bedard shut down the Rangers on one hit the rest of the way for his first save in a 10-season career.
Porter, who at 40 is baseball's youngest manager, insisted all spring that this team would be much better than last season.
"It's more about the concepts that we've implemented," Porter said. "They do a great job with the information we provide and it allows them to play with confidence and allows them to play fast."
As Houston began a new era with the move to the AL, the Rangers were embarking on a new chapter without 2010 AL MVP Josh Hamilton. Along with Hamilton's departure to the Angels, Texas also lost catcher Mike Napoli and infielder Michael Young.
The loss snapped a streak of four straight opening day victories by the Rangers. Former Astros star Lance Berkman had two hits in his first game as Texas' designated hitter.
"I think there have been some people who have been disparaging in their analysis of their talent level, but this is the major leagues, and any team is capable of beating any other team on a given night," Berkman said.
He isn't worried about their offense coming around.
"If you look at the back of our baseball cards, I think we're pretty stinking good," he said.
Matt Harrison (0-1), who signed a $55 million contract this offseason, yielded six hits and five runs and tied a career high with nine strikeouts in 5 2-3 innings.
Maxwell's two-out triple in the fourth inning broke a scoreless tie and gave Houston a 2-0 lead. The ball bounced off the wall in left field and scored Brett Wallace and Carlos Pena, who both got on with singles. Umpires reviewed the play to make sure it wasn't a home run, and upheld the call.
An error by right fielder Nelson Cruz let Houston score a run in the fifth, and Jose Altuve singled home another.
Harrison put runners at first and second with walks in the sixth and was replaced by Derek Lowe with two outs. Ankiel, the one-time pitcher with St. Louis, connected on his fifth career pinch-hit homer, a full-count shot to right field that made it 7-2.
Norris had a tough second inning and had to use 26 pitches to escape, striking out Mitch Moreland. Norris got on a roll from there, retiring nine of the next 10 batters.
Norris ran into trouble in the sixth when Ian Kinsler drew a walk and Berkman hit a one-out single. Murphy's two-out single sent Kinsler home to make it 4-1. Cruz followed with a groundball single that rolled just out of reach of diving shortstop Ronny Cedeno to score Berkman and chase Norris.
Chants of "Cruuuuuuuz" filled the stadium, indicating the large number of Rangers fans who made the 250-mile trip from Dallas. Norris was replaced by Erik Bedard, who is Houston's fifth starter, but won't be needed for a while in the rotation because of off-days. Monday's games
• Miami at Washington, 11:05 a.m.
• Boston at N.Y. Yankees, 11:05 a.m.
• San Diego at N.Y. Mets , 11:10 a.m.
• Chicago Cubs at Pittsburgh,
• Colorado at Milwaukee, 12:10 p.m.
• Detroit at Minnesota, 2:10 p.m.
• L.A. Angels at Cincinnati,
• S.F. at L.A. Dodgers, 2:10 p.m.
• Kansas City at Chicago White Sox, 2:10 p.m.
• L.A. Angels at Cincinnati,
• Philadelphia at Atlanta, 5:05 p.m.
• St. Louis at Arizona, 8:05 p.m.
• Seattle at Oakland, 8:05 p.m. Opener notes
Altuve got the first hit of the 2013 season.
These teams have a day off Monday before resuming the series on Tuesday when the Rangers' Yu Darvish opposes Lucas Harrell.
Houston Texans defensive end J.J. Watt, the NFL's defensive player of the year, threw out the ceremonial first pitch. Watt, who said he threw a bullpen session to prepare for the task, threw a strike.
Texans star receiver Andre Johnson was also in the sold-out crowd of 41,307.
Lyle Lovett performed the national anthem.