Principal ideal and free module Let $R$ be a commutative ring and $I$ be an ideal of $R$.
Is it true that $I$ is a principal ideal if and only if $I$ is a free $R$-module?
 A: Definitely not. Any proper principal ideal in a finite commutative ring is a counterexample.
On the other hand, a commutative ring is a principal ideal domain if and only if all of its nonzero ideals are free modules with unique rank. This is a result on "free ideal rings" (FIRs) studied by P.M. Cohn.

As you mentioned, it is easy to show that every principal ideal of a domain is isomorphic to $R$. (One way is to notice that $xR\cong R/ann(x)$, and $ann(x)=0$ if $x$ is nonzero.) 
Now suppose $J\neq 0$ is a free principal ideal of a commutative domain. Then $J\cong \oplus_{i\in I} R$ for some copies of $R$. In particular, $J$ this says (through the isomorphism) that $J$ has submodules corresponding to the copies of $R$, and so they are also ideals of $R$.
Suppose for a moment more than one copy of $R$ is used. Since the sum is direct, these copies have pairwise intersection zero. However, nonzero ideals of a domain always have nonzero intersection! To avoid this contradiction the sum can only have one term, hence $J\cong R$. Being isomorphic to a cyclic module, $J$ is itself cyclic (so it is a principal ideal).
A: It is true that, if $R$ is a commutative ring and $I$ is an ideal of $R$, then $I$ is free iff $I$ is principal and generated by a non-zerodivisor.
Proof: Say $I$ is free.  By way of contradiction, suppose $I$ has an $R$-basis containing more than one element.  Let $e_1$ and $e_2$ be distinct elements of this basis.  Then we have $e_2e_1-e_1e_2=0$, which is impossible, since the $e_i$ are linearly independent (this is where we use commutativity).  Thus, $I$ has finite rank, and its rank is $1$.  Say $I$ is generated over $R$ by $e \in R$; notice that $e$ must be a non-zerodivisor, or else $\{e\}$ would not be linearly independent.
Conversely, suppose $I$ is a principal ideal generated by a non-zerodivisor $e$.  Then the map $R \to I$ given by $r \mapsto re$ is an isomorphism of $R$-modules.
