Usually, for RGB images you just subtract half the range and divide by the full range:
$$x:=\frac{x-\frac{range}{2}}{range}$$
where $range=255$ in this case since each pixel is a value from 0 to 255.
This will not result in having zero mean and unit variance but for most applications it is close enough and works well.
If this is not working for you, the correct way to scale the data to have zero mean and unit variance is to take each channel individually; calculate the mean and variance of all the pixels in all the images in that channel; then scale each channel individually as follows:
$$x_R:=\frac{x_R-\mu_R}{\sigma_R} \;\; x_G:=\frac{x_G-\mu_G}{\sigma_G} \;\; x_B:=\frac{x_B-\mu_B}{\sigma_B}$$
Each pixel in a channel is the same feature, just in a different position in space, this is especially true when using a CNN.
Note: If $\sigma$ is too small for one or more of the channels you can cap it at minimum value to avoid numerical stability issues e.g. $\sigma= max(\sigma, 0.0001)$