Analytic first and second derivatives of the energy are developed for the fragment molecular orbital method interfaced with molecular mechanics in the electrostatic embedding scheme at the level of Hartree-Fock and density functional theory. The importance of the orbital response terms is demonstrated. The role of the electrostatic embedding upon molecular vibrations is analyzed, comparing force field and quantum-mechanical treatments for an ionic liquid and a solvated protein. The method is applied for 100 protein conformations sampled in MD to take into account the complexity of a flexible protein structure in solution, and a good agreement to experimental data is obtained: frequencies from an experimental IR spectrum are reproduced within 17 cm$^{-1}$.