This works for RPI 1 and 2. See links for RPI 3, where there are 2 serial ports and they have different names.
Edit /boot/config.txt to have:
Note: This option does not seem to always be in the default config.txt (maybe it depends on whether you use the version from NOOBS?)
Under Advanced -> Serial, choose No (that is, you do not want a login shell available through serial), save and reboot. This performs the steps that are usually given online (edit /boot/cmdline.txt and inittab).
Test with minicom (sudo apt-get install minicom):
minicom -b 9600 -o -D /dev/ttyAMA0