How have you tried to learn it? It's pretty much self-explanatory. I learned from books many many years ago but now there have to be hundreds if not thousands of free resources online.
Once you learn how to play the C,A,G,E, and D chords in open position, then learn how to play them at higher positions, e.g., the first fret. Then connect them up the fretboard in that order. Say you play a barred C major chord shape at the third fret. Your pinky finger is on the 6th fret of the fifth string, which is the root. This is E flat, and that is the chord you are playing. Now move up and play a barred A chord shape using that E flat 6th fret/fifth string as the root. You are still playing an E flat major chord but in the A shape. It goes up from there for G, E, and D shapes. Then each chord shape has its own box of major scale notes.