DNA nanomachines could initiate the cascade reaction in an autonomous mode under the drive of triggers, which achieve the signal amplification for the bioimaging of intracellular biomarkers. Compared with the "always-on" nanomachine that possibly produces false-positive signals, a controllable nanomachine with the on-site activation could be better for accurate tumor imaging and precise tumor therapy. Till now, the endogenous and exogenous triggers have been developed to design the controllable nanosensors. However, their combinations to develop feasible DNA nanomachines have been rarely studied. Herein, we constructed a near-infrared (NIR)-light-controlled DNA nanomachine that was first activated by the NIR light and then induced a target-triggered amplification process under the drive of an endogenous stimulus. Owing to adenosine-5'-triphosphate (ATP) having much higher concentration in cancer cells than that in healthy cells and the extracellular fluid, the obtained DNA nanomachine was selectively activated in cancer cells with inhibited interference signals from the surrounding healthy tissues. With obvious advantages including the exogenous NIR light initiation, the selective activation by the target microRNA, and the sensitive acceleration by the ATP-induced strand recycling reaction, the constructed nanomachine could be used to image the intracellular microRNA with increased sensitivity. Besides, after modifying the DNA sequence with the photosensitizer molecules, the obtained nanomachine could perform the selective photodynamic therapy on the tumor sections with the outstandingly decreased side effects. Thus, we hope the designed nanomachine could provide some important hints to design feasible nanomachines for accurate tumor diagnosis and precise tumor therapy.