如何为PHP5 / MySQL Web应用程序调试站点移动

I have been running a PHP site for years on my own servers. I recently purchased a dedicated server package and am trying to move my site to the dedicated server. I recently upgraded to PHP 5, and my current server is running PHP 5.6.16. I moved the files and the database, and put it in a live test domain, but the site is not functioning properly on the new dedicated server. Several key scripts are non-functional. I made sure that the dedicated server is running a version of 5.6. I have configured it to the same settings I have on the old server. I can see that the site is talking to the MySQL database. I turned on error reporting and I see no significant errors suggesting why these important scripts are now non-functional. I made sure the include path is there, and if it wasn't nothing would work. What am I overlooking? What could be different between one server and the other that might impact PHP functionality? I'm basically at my wits end here, so if these seems stupid please forgive me, but I don't know where to look next.

Start with the basics.

  • Does your web server respond to static page requests?
  • Is your web server configured to use PHP?
  • Can your web server execute and/or connect to PHP?
  • If you have a simple script with <?php phpinfo(); in it, does it work?
  • Are all the expected modules there in your phpinfo() output?
  • Do you have rewrite rules that need to be reconfigured? (Check your web server error log. Check your response status codes.)

Assuming PHP is all good, move into your application.

  • Are you absolutely sure error logging is on? (Again, check phpinfo() output. Try to force an error, maybe a syntax error or something and see if you see the error.)
  • How do you know your application is connecting to MySQL?
  • Start with a basic script that just echos some things.
  • Comment out large swaths of code and see if you can narrow down the problem that way, re-enabling chunks as you go. (You want to bi-sect the problem, cutting in half and in half and in half until you figure out exactly what the issue is.)

Other system-level things to check...

Once you figure out the problem, some advice:

  • Do this sort of thing regularly. Write a provisioning script to build yourself a new machine from one command, and do it regularly. These days with cloud providers (physical hardware or not) there's no reason you can't blow away your application servers on a regular basis, and re-provision them. Consider making this your system upgrade strategy. (Why reboot to get a new kernel when you can just have a whole new server with the new kernel and other patches, that you can cut over to?)
  • Ensure your development environment closely matches your production environment. (Consider Vagrant for this.)
  • You're using version control, right? If not, start using version control so that you can hack on your code for things like this and easily roll back when done.