Why does the modulus of Diffie–Hellman need to be a prime? I read a lot about Diffie-Hellman, but there is one thing I dont understand: why does the modulus p need to be a prime? What if it would not be a prime?
Answer to Martin's and Vadim's comments:

Let $n:=p$ and you want to find $x$ with $g^{x} \equiv y \bmod pq$

Calculate the two easier DL problems:
 ${x_p}$ with $g^{x_p} \equiv y \bmod p$
 ${x_q}$ with $g^{x_q} \equiv y \bmod q$  

Note that
$x_p \equiv x \bmod p-1$
$x_q \equiv x \bmod q-1$ 

With the chinese remainder theorem you can calculate $x'$ from $x_p$ and $x_q$ with
$x' \equiv x \bmod lcm(p-1, q-1)$