The gut microbial communities interact with the host immunity and physiological functions. In this study, we investigated the bacterial composition in Litopenaeus vannamei shrimp’s gut and rearing water under different host (developmental stage: juvenile and adult; health status: healthy and diseased) and environmental factors (temperature 25 °C and 28 °C; and light intensity: low and high). The PCoA analysis showed that all water samples were clustered together in a quarter, whereas the gut samples spread among three quarters. In terms of functional bacteria, gut samples of adult shrimp, healthy adult shrimp, adult shrimp raised at 28 °C, and juvenile shrimp under high light intensity exhibited a higher abundance of Vibrionaceae compared to each other opposite group. Gut samples of juvenile shrimp, infected adult shrimp, juvenile shrimp with low light intensity, and adult shrimp with a water temperature of 25 °C showed a higher abundance of Pseudoaltromonadaceae bacteria compared to each other opposite group. Gut samples of juvenile shrimp, healthy adult shrimp, adult shrimp raised at a water temperature of 28 °C, and juvenile shrimp with high light intensity showed the higher abundance of Firmicutes/Bacteroidota ratio compared to each other opposite group. Our results showed that L. vannamei juveniles are more sensitive to bacterial infections; besides, water temperature of 28 °C and high light intensity groups were both important conditions improving the shrimp gut bacterial composition under industrial indoor farming systems.Key points• Bacteria diversity was higher among shrimp intestinal microbiota compared to the rearing water.• Shrimp juveniles are more sensitive to bacterial infection compared to adults.• Water temperature of 28 °C and high light intensity are recommended conditions for white shrimp aquaculture.Graphical