Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Question: Is there a way to test for correctness once the SQL DB copy has been installed on the local machine so I can confidently move to step number 3? Is there any information on the web that would help with the below goals? Are the below goals even possible or a good idea?

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 store and its corresponding MySQL database without being at risk of messing something completely up on the live servers.

My current plan of action:

  1. Set up a VM with debian server, MySQL, PHP, Apache(or something else)
  2. Copy my current MySQL databases from my hosting provider and install on VM server.
  3. Copy web store (PHP/HTML) code to 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.

Now I'm pretty sure I have step one down correctly but I can't for the life of me figure out where to began for steps 2 and 3. I've looked online for resources about how to make a 1 to 1 copy and install the database on a different machine but none of the information seems to be working or correct for my SQL DB (MySQL).

share|improve this question
    
Hmmm, can you define correctness.. Do you mean CRC checking the database or something. –  bybe Mar 24 '13 at 18:58
    
pretty much just making sure it works exactly the same on the VM as it does on my live host. I've taken 1 MySQL class in my collage career so I'm not a complete noob, which means I know that just copying the values in the table aren't enough I also need other db variables. –  TdotThomas Mar 25 '13 at 16:56

2 Answers 2

up vote 1 down vote accepted

This is exactly what I do all the time. There is a full LAMP stack installed locally on my home machine. The hosting provider also uses LAMP and between cPanel and the output of php_info(), I know which software versions to match both configurations.

All you need is to make sure the files (PHP/HTML/CSS/JPEG/PNG/etc) are the same which you can do with rsync (or an FTP GUI client with synchronization feature) and to transfer the database. Doing the DB transfer is fairly easy. If you have access to the command-line you use a MySQL prompt to export the database on the hosting server and you import it locally.

Without the command-line you can do the export/import using a tool like phpMyAdmin. Just make sure that the export is done with the DROP option enabled so that everything gets overridden later when you import. For import, you need to make sure your PHP file upload limit is large enough to allow your DB to be transferred. The default is fine for small DBs but with a large site it needs to be boosted.

share|improve this answer
    
How do you handle your websites domain name being everywhere in your code? For example on my computer I have my /etc/host file set up so that that www.MySite.test goes to the IP address of my VM server but once I import my PHP, HTML, and SQL everything will reference www.MySite.com how do I make sure PHP, HTML, and SQL to work correctly? –  TdotThomas May 29 '13 at 7:53
    
@TdotThomas - It is not. For most sites I use root relative links, so all links start with / but have no domain name. This makes working with rewrite rules simpler. Some of my older sites used purely relative links. For the rare cases I need a domain name, I have a PHP variable which is set based on the request address which is a static private IP on my local number. Locally I access it through a convenience domain, so say foo.com/ would be locally foo/. The only thing that I avoid completely is having the domain name in the database. –  Itai May 29 '13 at 12:17

Downloading the entire mysql db will also ensure that the configuration variables (such as domain name, server path, et al) are also copied. These things may not be the same on your test server.

Find a way to setup an empty webstore, export data from your live and import to your test. The way you would do for a WordPress installation.

share|improve this answer
    
How do I download the entire MySQL DB and install it on my VM? –  TdotThomas Mar 26 '13 at 0:00
    
mysqldump command –  Prasad Mar 26 '13 at 4:39
    
are there any tests I could run to make sure everything is working the same? –  TdotThomas Mar 31 '13 at 7:55
    
How do you handle your websites domain name being everywhere in your code? For example on my computer I have my /etc/host file set up so that that www.MySite.test goes to the IP address of my VM server but once I import my PHP, HTML, and SQL everything will reference www.MySite.com how do I make sure PHP, HTML, and SQL to work correctly? –  TdotThomas May 29 '13 at 7:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.