A useful way of looking at the notes on the guitar fretboard is to think in terms of positions. The position you are playing is determined by the fret closest to the first finger of your left hand.
For example, if you are playing a melody or chord where your first finger stays at the first fret, then you are in the first position. If your first finger stays at the 6th fret, you are in the 6th position, etc.
The following example demonstrates a short phrase played in several different positions, as shown in the tablature. Experiment and find out how many other positions you can use to play this phrase.
This solo moves freely between all the forms of the major scale. Once you have learned it, use the ideas to create your own lines.