I have the action
$$S=\int d^4x\sqrt{-g}\Big[\frac{1}{8}\phi^2R-\frac{1}{2}g^{\mu\nu}\partial_\mu\phi\partial^\nu\phi-\frac{1}{2}m^2\phi^2\Big]$$$$S=\int d^4x\sqrt{-g} \Big[\frac{1}{8}\phi^2R- \frac{1}{2}g^{\mu\nu}\partial_\mu\phi\partial_\nu\phi - \frac{1}{2}m^2\phi^2\Big]$$ where $\phi$ is a scalar field and $R$ is the scalar curvature (signature $-+++$)
I want to get the equations of motion and then substitute in the FRW metric.
Could someone show me how to vary this action?
Alternatively could I simply substitute the FRW metric into the above action and then calculate the Euler-Lagrange equations for the scale factor $a(t)$ and the scalar field $\phi$?
I guess in that case I would only get two equations rather than the three I would get by substituting the FRW metric into the full equations of motion.