A variational calculation is performed of the eigenstates of a positronium atom coupled with a field of longitudinal acoustic phonons in ionic crystals at finite temperatures. On the basis of this calculation a theoretical analysis is made of the possibility of self-localization ͑self-trapping͒ of positronium. The self-trapped states of positronium in NaF, NaCl, KCl, and KI crystals are found to be metastable with the energy higher by ϳ0.01-0.1 eV with respect to the stable delocalized ͑free͒ states. The self-trapped states of positronium in MgF 2 and ␣-SiO 2 crystals are unstable at absolute zero temperature and become metastable with an increase in temperature for TϾϳ300 K. The difference in the energies of such ''high-temperature'' self-trapped states and the free states of positronium in MgF 2 and ␣-SiO 2 is found to be at least one order of magnitude larger than that in the other alkali halides, explaining theoretically experimental evidence for the nonexistence of self-trapped positronium in these crystals. The basic characteristics ͑energy, effective mass, mean number of surrounding phonons, and localization radius͒ of the self-trapped and free states as well as the deformation potential constants are calculated for positronium in the crystals above. The results obtained are in good agreement with known experimental data.