A search is presented for the production of two Higgs bosons in final states containing two photons and two bottom quarks. Both resonant and nonresonant hypotheses are investigated. The analyzed data correspond to an integrated luminosity of 19.7 fb(-1) of proton-proton collisions at root s = 8 TeV collected with the CMS detector. Good agreement is observed between data and predictions of the standard model (SM). Upper limits are set at 95% confidence level on the production cross section of new particles and compared to the prediction for the existence of a warped extra dimension. When the decay to two Higgs bosons is kinematically allowed, assuming a mass scale Lambda(R) = 1 TeV for the model, the data exclude a radion scalar at masses below 980 GeV. The first Kaluza-Klein excitation mode of the graviton in the RS1 Randall-Sundrum model is excluded for masses between 325 and 450 GeV. An upper limit of 0.71 pb is set on the nonresonant two-Higgs-boson cross section in the SM-like hypothesis. Limits are also derived on nonresonant production assuming anomalous Higgs-boson couplings.