Rare-gas solids (Ne, Ar, Kr, and Xe) under hydrostatic pressure up to 30 kbar have been studied by path-integral Monte Carlo simulations in the isothermal-isobaric ensemble. Results of these simulations have been compared with available experimental data and with those obtained from a quasiharmonic approximation (QHA). This comparison allows us to quantify the overall anharmonicity of the lattice vibrations and its influence on several structural and thermodynamic properties of rare-gas solids. The vibrational energy increases with pressure, but this increase is slower than that of the elastic energy, which dominates at high pressures. In the PIMC simulations, the vibrational kinetic energy is found to be larger than the corresponding potential energy, and the relative difference between both energies decreases as the applied pressure is raised. The accuracy of the QHA increases for rising pressure.