y''=(1/EI)*mgL - (1/EI)*x + (1/2)*(1/EI)*pg*L^2 - (1/2)*(1/EI)*pg*(2L)*x + (1/2)*(1/EI)*pg*x^2.
This looks like a big mess, but everything except for x is a constant. So let me rewrite this as
The antiderivative of the sum is equal to the sum of the antiderivatives, so just take antidervivative of each term individually.
y'=Ax+(1/2)Bx^2+Cx+(1/2)Dx^2+(1/3)Fx^3 + K (a new constant)
Take the antiderivative of each of these terms, and you are done! (just plug in the more complicated looking constant values)