2-Phenylethanol (2-PE) and indole-3-acetic acid (IAA) are important secondary metabolites produced by microorganisms, and their production are closely linked to the growth state of microorganisms and environmental factors. Enterobacter CGMCC 5087 can produce both 2-PE and IAA depending on α-ketoacid decarboxylase KDC4427. This study aimed to investigate the effects of different environment factors including osmotic pressure, temperature, and pH on the synthesis of 2-PE and IAA in Enterobacter sp. CGMCC 5087. The bacteria exhibited an enhanced capacity for 2-PE synthesis while not affecting IAA synthesis under 5% NaCl and pH 4.5 stress conditions. In an environment with pH 9.5, the synthesis capacity of 2-PE remained unchanged while the synthesis capacity of IAA decreased. The synthesis ability of 2-PE was enhanced with an increase in temperature within the range of 25 °C to 37 °C, while the synthesis capacity of IAA was not affected significantly. Additionally, the expression of KDC4427 varied under stress conditions. Under 5% NaCl stress and decreased temperature, expression of the KDC4427 gene was increased. However, altering pH did not result in significant differences in gene expression levels, while elevated temperature caused a decrease in gene expression. Furthermore, molecular docking and molecular dynamics simulations suggested that these conditions may induce fluctuation in the geometry shape of binding cavity, binding energy, and especially the dαC-C- value, which played key roles in affecting the enzyme activity. These results provide insights and strategies for the synthesis of metabolic products 2-PE and IAA in bacterial fermentation, even under unfavorable conditions.