If you look at the following example, you will notice a line of letters and symbols above the staff (Cmaj7, Dm7, etc). These chord symbols indicate the harmony to be played by accompanying instruments, such as keyboard or another guitar.
Here is a simple solo derived from the notes of the C major scale. Learn it from memory and then experiment with the ideas and note sequences to create your own melodies. Try using the same rhythm and harmony, but create your own different melodies. This process is called improvising.
Here is another solo derived from the C major scale in the open position. You will note that it sounds different from the previous example. The main change is in the rhythm and phrasing; the notes still reflect the chords in the harmony (backing).
This is an important principle to follow when soloing over any chord progression. Try experimenting with the following melody, but keep the first note in each bar the same as in the original, so that it still reflects the chords.