Apple replant disease (ARD) is a common and destructive disease in apple orchards with long cultivation histories. In the present study, soils from three apple orchards under cultivation for two years (G2), thirty years (G30), and forty years (G40) were used to investigate the key nutritional factors influencing soil bacterial community structure. Changes in nutrient concentrations in the orchard soil entailed reductions in concentrations of medium trace nutrients (magnesium [Mg], manganese, and nickel) and the increase in concentrations of macronutrients (total nitrogen [TN], total phosphorus, total potassium, available phosphorus, and available potassium) and soil organic carbon. As cultivation time was prolonged, bacterial community composition shifted from enrichment with oligotrophic Acidobacteria and plant growth-facilitated Streptomyces to increased abundance of copiotrophic taxa, Bacteroidetes and Firmicutes, and plant-growth-impairing Gemmatimonas, based on 16S rDNA (V4) amplicon sequencing data. In addition, the relative abundances of bacteria associated with fermentation function and the decomposition of some unique compound classes increased, while the relative abundance of bacteria associated with the nitrification function decreased. Among all the nutritional elements tested using distance-based multivariate linear model analysis, Mg and TN influenced community structure the most. The results provide novel insights into the associations between soil nutrients and shifts in microbial community structure under long-term apple orchard soil ecosystems.