Intragastric pH acts an important role in the disintegration of food and therapeutic drugs. The generation of some gastric diseases, such as gastric ulcer, gastritis or gastric cancer, may affect the normal secretion of gastric acid, causing abnormal pH in the stomach. Thus, monitoring the pH-fluctuations in stomach could aid the diagnosis of several gastric diseases and in understanding therapeutic effect. Herein, we developed a near-infrared (NIR) fluorescent probe (Cyp) for the real-time and in-situ imaging pH changes in vitro and in vivo. The probe was designed by integrating dimethylamine moiety into cyanine (Cy7) and displayed an increasing NIR emission with pKa values of ca. 4.38 in PBS buffer from pH 2.0 and 7.0. Moreover, the robust probe can detect the pH fluctuations in the living cells during autophagy and drug stimulation. Importantly, the unique probe Cyp could dynamically and real-time in situ image the pH fluctuations in gastrointestinal caused by anti-acid medicine with deep penetration. As a typical gastric disease, gastric ulcer was successfully diagnosed by using the powerful pH probe, for the first time. Both the in vitro and in vivo experiments show that the robust probe has a potential application in imaging-guided gastric diseases diagnostics and therapeutics.