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.
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!
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.
Click below to sign up and get $200 of credit to try our products over 60 days!
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:
Once you have your local dev environment up and running, you could download your website files via SFTP with a tool like FileZilla:
Regarding your database, you could use the
mysqldumpcommand-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:
Hope that this helps! Best, Bobby