Due to its band-gap energy, gallium nitride (GaN) is well-suited for light emission in the blue spectral region. By alloying with aluminium and/or indium, an energetical range even wider than the whole visible spectrum can be covered. For electronic devices based on group-III nitrides, the influence of strain is a non-negligible intrinsic physical effect. An easy way to experimentally evaluate the strain is the monitoring of lattice vibrations via Raman spectroscopy. With experimental data providing a reliable reference for the strain effects not being available, it is desirable to obtain them from a full quantum-mechanical treatment of the material via first-principles calculations. In this work, the strain dependence of the structural and dielectric properties and of the phonon frequencies of the cubic and the hexagonal polytype of GaN and AlN as well as of short-period superlattices are investigated by ab-initio methods. Three types of strain are considered, corresponding to the application of hydrostatic pressure, of an isotropic biaxial stress in the basal plane, and of a uniaxial pressure along the crystal axis. After a careful internal relaxation of the structures for given external stress, the dielectric constant, Born effective charges and phonon frequencies are calculated using density-functional perturbation theory. Since typical structural changes are of the order of one hundredth of the lattice parameters, to resolve these changes to a precision of a few percent the lattice parameters themselves have to be determined to a precision of 1E-4, which indeed can be achieved. The elastic properties of GaN and AlN are characterized in terms of ratios of the elastic stiffness constants, which allow for a critical comparison with literature data; unreliable ones are pointed out. The calculated pressure behavior of the phonon modes compares rather well to experimental results. The observed increase of the LO-TO splitting results from a reduced dielectric screening, not from an increase in ionicity. A frozen-phonon calculation shows that the softening of the low-frequency E2 mode is mainly caused by an increased destabilization due to the Ewald energy, which is differently counterbalanced in GaN and AlN by the other contributions to the total energy. From the strain dependences, phonon mode coefficients and deformation potentials are obtained, which agree with measured values for GaN; for AlN, no other published values are available. Seeming discrepancies between experimental and theoretical results can be widely resolved using suitable parameters and correct stress-strain relations. We find that the stress obtained from biaxial-strain-induced shifts of the high-frequency E2 phonon should be higher than determined by other authors. The short-period superlattice show a structural relaxation behavior differing significantly from the bulk one. Their phonon modes are grouped in separate frequency regions for LO and TO modes as well as for acoustic ones, they exhibit properties typical both for thicker superlattices as well as for a bulk material of its own kind. Folded AlN-confined TA modes appear due to the mutual strain of the GaN and AlN layers. For all superlattices, independent of the number of layers and the polytype, the following special features are found, which can be considered as intrinsic properties: All but one of the TO modes are confinded modes, with the propagating one being found in the GaN frequency region, well separated from the AlN range; it shows a vibrational pattern similar to a bulk zone-center TO mode. In the gap between the AlN- and GaN-confined TO modes an interface mode exists, showing strong angular dispersion. The uppermost LO mode changes its polarization direction and it is strongly IR active, thus for all propagation directions it couples to the electric field, in complete analogy to the polar LO mode of bulk material.