The simple answer is to create a literary work. In U.S. Copyright language a "literary work" could be a book, manuscript, online work, poetry, or other text; published or unpublished, with or without illustrations. Computer programs and databases also are considered literary works.
In other words a copyright is secured automatically upon creation of a literary work.
That was easy.
Here's the official story from the -
"The way in which copyright protection is secured is frequently misunderstood. No publication or registration or other action in the Copyright Office is required to secure copyright. (See following Note.) There are, however, certain definite advantages to registration.
Copyright is secured automatically when the work is created, and a work is 'created' when it is fixed in a copy or phonorecord for the first time. 'Copies' are material objects from which a work can be read or visually perceived either directly or with the aid of a machine or device, such as books, manuscripts, sheet music, film, videotape, or microfilm. 'Phonorecords' are material objects embodying fixations of sounds (excluding, by statutory definition, motion picture soundtracks), such as cassette tapes, CDs, or LPs. Thus, for example, a song (the 'work') can be fixed in sheet music (' copies') or in phonograph disks (' phonorecords'), or both.
If a work is prepared over a period of time, the part of the work that is fixed on a particular date constitutes the created work as of that date."
You can register a literary work through the U.S. Copyright Office by filling out a form and sending them 30 dollars.