In an effort to minimize operational expenses and supply users with more scalable services, distributed applications are actually going towards the Cloud. These applications, sent out over multiple environments and machines, are composed by inter-connecting independently developed services and components. The implementation of such programs on the Cloud is difficult and generally carried out either by hand or perhaps by composing personalized scripts. This is extremely error prone plus it has been found that misconfiguration may be the root of huge mistakes. We introduce AutoBot, a flexible platform for modeling, installing and (re)configuring complex distributed cloud-based applications which evolve dynamically in time. AutoBot includes three modules: A simple and new model describing the configuration properties and interdependencies of components; a dynamic protocol for the deployment and configuration ensuring appropriate resolution of these interdependencies; a runtime system that guarantee the proper configuration of the program on many virtual machines and, if necessary, the reconfiguration of the deployed system. This reduces the manual application deployment process that is monotonous and prone to errors. Some validation experiments were conducted on AutoBot in order to ensure that the proposed system works as expected. We also discuss the opportunity of reusing the platform in the transition of applications from Cloud to Fog computing.A preliminary version of this paper appeared in IEEE SoICT 2016, December 08-09, Ho Chi Minh City, Vietnam. This version extends the D&C protocol significantly to cover deployment and dynamic reconfiguration for distributed applications not only in Cloud computing but also beyond the Cloud such as Fog computing. Current related work is also updated to cover the state-of-the-art. New experiments were conducted to validate the flexibility and portability of our approach in both Cloud and Fog environment.