We present a theory of phonon-mediated superconductivity in near magic angle twisted bilayer graphene. Using a microscopic model for phonon coupling to moiré band electrons, we find that phonons generate attractive interactions in both s- and d-wave pairing channels and that the attraction is strong enough to explain the experimental superconducting transition temperatures. Before including Coulomb repulsion, the s-wave channel is more favorable; however, on-site Coulomb repulsion can suppress s-wave pairing relative to d wave. The pair amplitude varies spatially with the moiré period, and is identical in the two layers in the s-wave channel but phase shifted by π in the d-wave channel. We discuss experiments that can distinguish the two pairing states.