The complex interplay between an animal and its surrounding environment requires constant attentive observation in natural settings. Moreover, how ecological interactions are affected by an animal's genes is difficult to ascertain outside the laboratory. Genetic studies with the bacterivorous nematode Caenorhabditis elegans have elucidated numerous relationships between genes and functions, such as physiology, behaviors, and lifespan. However, these studies use standard laboratory culture that does not reflect C. elegans true ecology. C. elegans is found growing in nature and reproduced in large numbers in soils enriched with rotting fruit or vegetation, a source of abundant and diverse microbes that nourish the thriving populations of nematodes. We developed a simple mesocosm we call soil-fruit-natural-habitat that simulates the natural ecology of C. elegans in the laboratory. Apples were placed on autoclaved potted soils, and after a soil microbial solution was added, the mesocosm was subjected to day-night, temperature, and humidity cycling inside a growth chamber. After a period of apple-rotting, C elegans were added, and the growing worm population was observed. We determined optimal conditions for the growth of C. elegans and then performed an ecological succession experiment observing worm populations every few days. Our data showed that the mesocosm allows abundant growth and reproduction of C. elegans that resembles populations of the nematode found in rotting fruit in nature. Overall, our study presents a simple protocol that allows the cultivation of C. elegans in a natural habitat in the laboratory for a broad group of scientists to study various aspects of animal and microbial ecology.