Question: **Info:** I would like to set up a VM server on my local computer which will serve pages in the exact same way as my current hosting (but only to me on my local computer). I currently pay a big web hosting company to host my website & web store and they are doing a great job, but I would like to be able to work on my Web site and its corresponding MySQL DB, HTML, and PHP code without being at risk of messing something completely up on the live servers.

My current plan of action:

1. Set up a VM webserver with Debian, MySQL, PHP, Apache.
2. Copy web store (PHP/HTML) code to VM server.
3. Copy my current MySQL databases from my hosting provider and install
on VM server.
4. Modify and test new features on VM server.
5. Upload MySQL DB and HTML/PHP code back to web host's server where it
should work as before but with new modifications.

**Questions:** Now I'm pretty sure I have steps one and two down correctly but I can't for the life of me figure out how to proceed next, so here are my questions.

I have my /etc/host file set up so www.MySite.test redirects to the IP address of the local VM webserver. Once I import my PHP/HTML files and MySQL file whats the best way to navigate around the fact that all of my files and DBs will reference www.MySite.com.

I can export my MySQL dbs but do I also have to export my MySQL users and passwords to access those db or are those coded into my html/php code?

Answer: 
The thing with projects like this is it never really works the way its suppose to I've imported my database and my HTML/PHP/JS code but something is never right. To those reading about doing this its more then just code and a database, its permissions, users, etc, etc. Below are somethings I've learned, some advice, and tools I've used.

1. I'm using Virtual Box it has a great snapshot feature, great support for my Host OS of choice(Debian) and my Guest OS of choice(Debian), and its free.
2. I'm only using free software/webware the online support is better and I'm broke.
3. Take a ton of snapshots and backups.
4. Keep everything with documented.
5. If you get stuck ask for help.
6. Setup host only networking so that you can get to www.YourSite.test
7. Remove as much unneeded software as you can to increase performance and limit potential bugs.

This was a good idea but its a lot more work then just setting up some software. The info on this page is a good place to start but do your own research because there is a lot of stuff to learn even if you consider yourself a pro.
not really: if you know where your code stores db access details you can create a single user on you VM mysql instance and usa those credentials to access all dbs, and configure with such details all your code