From Wikipedia:
Gomer Pyle, U.S.M.C. is an American situation comedy that originally aired on CBS from September 25, 1964, to May 2, 1969. The series was a spin-off of The Andy Griffith Show, and the pilot episode was aired as the season finale of the fourth season of its parent series on May 18, 1964. The show ran for five seasons and a total of 150 episodes. In 2006, CBS Home Entertainment (distributed by Paramount) began releasing the series on DVD. The final season was released in November 2008.
Gomer Pyle, U.S.M.C. was a hit, never placing lower than tenth in the Nielsen ratings, and ended its run as the second-highest-rated series in the United States. It has enjoyed continued popularity through reruns and DVD releases. The series was created by Aaron Ruben, who also produced the show with Sheldon Leonard and Ronald Jacobs. Filmed and set in California (originally set in North Carolina), it stars Jim Nabors as Gomer Pyle, a naive but good-natured gas station attendant from the town of Mayberry, North Carolina, who enlists in the United States Marine Corps. Frank Sutton plays Gomer's high-octane, short-fused Gunnery Sergeant Vince Carter, and Ronnie Schell plays Gomer's friend Duke Slater. Allan Melvin played in the recurring role of Gunnery Sergeant Carter's rival, Sergeant Charley Hacker.
The show was produced by creator Aaron Ruben, The Andy Griffith Show producer Sheldon Leonard (in partnership with Griffith), and Ronald Jacobs; it was co-produced by Bruce Bayley Johnson and Duke Vincent. Among the writers were Sam Bobrick, Harvey Miller, Aaron Ruben, Jack Elinson, and Bill Idelson; The Andy Griffith Show writers Everett Greenbaum and Jim Fritzell also wrote episodes. Coby Ruskin was the primary director in the first four seasons, before John Rich took over the role for the fifth season; other directors included Gary Nelson, Peter Baldwin, and Alan Rafkin. Ruth Burch was in charge of the casting, and John Finger directed the cinematography. The theme song was composed by Earle Hagen, who also composed the themes for shows such as The Andy Griffith Show, The Dick Van Dyke Show, and That Girl. The show was filmed at Camp Pendleton, Desilu Studios's Desilu-Cahuenga, and RKO Forty Acres backlot, where The Andy Griffith Show was filmed. Though Ruben preferred the use of a multiple-camera setup for comedy programs, Gomer Pyle used a single-camera setup because much of the shooting was conducted outdoors. In his book "And The Show Goes On," Sheldon Leonard explained that the armed forces offer levels of "cooperation" with filmmakers. Because the Marines felt that the show would be good for the branch's image, Gomer Pyle was given "total cooperation," meaning that the show was allowed unlimited access to military equipment.
Nabors and Sutton were the only actors credited in every episode (however, Sutton did not actually appear in every episode). Ronnie Schell (who played Duke Slater) left after the third season to star in Good Morning, World, though he returned for the fifth season, promoted to corporal, after graduating from non-commissioned officer training. Roy Stuart, who played Corporal Chuck Boyle, made his debut in the second season and left after the fourth. Andy Griffith, Frances Bavier, Ron Howard, and George Lindsey made guest appearances on the series reprising their respective roles from The Andy Griffith Show. Denver Pyle and Allan Melvin, who both had roles on The Andy Griffith Show, appeared in Gomer Pyle, but did not reprise their original roles. Denver Pyle, who had played Briscoe Darling in six episodes of The Andy Griffith Show, played tomato farmer Titus Purcell in the Gomer Pyle episode "The Price of Tomatoes". Allan Melvin, who had played Clarence "Doc" Malloy and other antagonists on The Andy Griffith Show, played Sergeant Carter's rival, Staff Sergeant Hacker, for four seasons. Nabors also carried the Gomer Pyle character to fellow CBS series The Lucy Show, in which he made a cameo appearance in a 1966 episode.