Leakage from cementitious structures with a retaining function can have devastating environmental consequences. Leaks can originate from cracks within the hardened cementitious material that is supposed to seal the structure off from the surrounding environment. Bioactive self-healing concretes containing bacteria capable of microbially inducing CaCO3 precipitation have been suggested to mitigate the healing of such cracks before leaking occurs. An important parameter determining the biocompatibility of concretes and cements is the pH environment. Therefore, a novel ratiometric pH optode imaging system based on an inexpensive single-lens reflex (SLR) camera was used to characterize the pH of porewater within cracks of submerged hydrated oil and gas well cement. This enabled the imaging of pH with a spatial distribution in high resolution (50 μm per pixel) and a gradient of 1.4 pH units per 1 mm. The effect of fly ash substitution and hydration time on the pH of the cement surface was evaluated by this approach. The results show that pH is significantly reduced from pH >11 to below 10 with increasing fly ash content as well as hydration time. The assessment of bioactivity in the cement was evaluated by introducing superabsorbent polymers with encapsulated Bacillus alkalinitrilicus endospores into the cracks. The bacterial activity was measured using oxygen optodes, which showed the highest bacterial activity with increasing amounts of fly ash substitution in the cement, correlating with the decrease in the pH. Overall, our results demonstrate that the pH of well cements can be reliably measured and modified to sustain the microbial activity.