Building any security system - whether it's password protection for an E-Book or installing a deadbolt on your front door - requires taking some time to slow down and understand the different ways that people can bypass any given security system (these are called attack vectors). It's no good to install a deadbolt on a door that has glass window panes, for example.
The best way to fast track this is to hire someone who's done it before. If you fast track your learning process, you're going to miss some basic circumvention techniques (attack vectors) that people will use to read your Ebook for free.
Yes, there are Scripts that you can install - check out the PHP section at http://www.hotscripts.com Doing that will be somewhat more secure than trying to build this yourself as a first project. The problem with installing someone else's code is that you don't know what attack vectors the author planned for. If you build it yourself, then you know exactly where you're protected but you might not know where you're not. If you hire an experienced programmer, they should be able to document what you are and aren't protected against - and knowing where you're weak is one of the most important parts about security.