Question

Creating a local environment from an existing droplet?

I have a custom site running on an Ubuntu LAMP 16.04 droplet. The site is built with PHP and has entries in a SQL database.

What’s the best way to clone this droplet as-is (SQL database and all) and run it locally? Once local I’ll configure it with Git and use GitHub Actions to rsync back to the production server.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hello,

It would depend on what OS you are using on your local environment. For example, if you have a Windows PC, you could install the WAMP stack which would allow you to have Apache/PHP/MySQL on your laptop. If you have a Mac, you could do the same with MAMP:

https://www.mamp.info/en/mac/

Once you have your local dev environment up and running, you could download your website files via SFTP with a tool like FileZilla:

https://docs.digitalocean.com/products/droplets/how-to/transfer-files/

Regarding your database, you could use the mysqldump command-line tool to export a backup of your database and import it to your local environment after that:

How to export/backup a MySQL/MariaDB database with mysqldump

Alternatively, what I like to do personally is to have an exact copy of my production server rather than run my projects on my laptop. So what I usually do is to restore a backup of my production server and use it as a development environment/server.

Then I use VS Code with an extension called Remote-SSH, which allows me to connect to my server via SSH through VS Code and I am able to make changes to my project directly on the dev server just as I would if it was an actual local project.

Here is a great tutorial on how to do that:

https://www.digitalocean.com/community/tutorials/how-to-use-visual-studio-code-for-remote-development-via-the-remote-ssh-plugin

Hope that this helps! Best, Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.