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: 
Although it looks like Stephen answered your question I figured I would respond to the title of the question, "Setting up a LAMP VM server for Development and Testing?"

1. Get [Virtual Box](//www.virtualbox.org), it's free and easy to use.
2. Get the ISO for [Ubuntu](//www.ubuntu.com), [Debian](//www.debian.org) or the operating system that best mimics your production environment. You might have to spend money. Microsoft offers an evaluation version of [Windows Server](//technet.microsoft.com/en-us/evalcenter/hh670538.aspx?ocid=&wt.mc_id=TEC_108_1_33). I don't have experience with these but heard that the evaluation versions of Windows expire after some date.
3. Get [Xampp](http://www.apachefriends.org/en/xampp.html) for your OS because it installs and configures PHP and MySQL for you. It also includes phpMyAdmin and an email server that have come in handy.
4. Install Virtual Box.
5. Run Virtual Box and then install the OS on it using the ISO you downloaded.
6. Install Xampp on your mint virtual boxed OS. Write down those usernames and passwords, or make them easy to guess. This is a local development and testing environment after all.
7. Use Virtual Box to create a backup of your virtual machine image. This will make starting over and setting up a new environment a breeze.
8. Dance, you deserve it.

Also, I second the suggestion to use source control. It doesn't matter to me what you use, just use it. I'd also recommend that you backup your hard work, and your client's investment. Embracing source control will change how you work for the better.
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