A novel naphthalimide-based solid-phase fluorescence pH sensor (PS-Acyl-II) is prepared by immobilization of a small molecule probe (II) on polystyrene microspheres through an ester bond and is characterized by Fourier-transform infrared spectroscopy, optical microscope, scanning electron microscope, and conductiometric titrations. The sensor can determine the pH of a solution within the pH 4.0–7.0, free from interference of common metal ions, and can be reused several times. The geometries of II, PS-Acyl-II, and its product with H+ are optimized at the B3LYP/6-31G** level by density functional theory. The charge distribution, orbital interactions, and bonding characteristics are analyzed and compared in detail to discuss the recognition mechanism and structure–fluorescence property relationships.