What you're really looking for are solutions to two different (but closely-related) problems that stack on top of each other:
- Configuration management
- Deployment automation
There's some overlap between the two, and as you're starting out it will probably be a little bit fuzzy which tools to use for which parts of your infrastructure. Here are some general guidelines to get you started, though:
Configuration management tools generally follow a resource-oriented, idempotent model. That is, you model your system as a set of resources that have state, and you run your configuration management tool continuously to see if anything looks different from your specification. If the resource is not in that state, you have some type-specific logic to bring the resource into that state. A package or a user account is a simple and obvious kind of resource, but you might also have ElasticSearch templates, entries in your SELinux database, or Nagios hosts that can also be declared as resources in your configuration management system of choice.
As a quick example, a package may be installed or not installed, and it may have a version attached. A configuration management tool will be able to take a configuration specification that says package X should be installed, see that it's not currently installed, and take the right steps to bring it from not installed to installed state (obviously, by installing it).
Idempotence means that you can apply the same configuration ten, a hundred, or a thousand times and get the exact same result -- only the things that need changing are actually changed. This is in contrast to a script that might, say, append a line to a configuration file a hundred times (meaning you end up with the same line in that file a hundred times).
The disadvantages of a configuration management system using this model are that the associations between your resources are fairly loose, they don't map well to long-running tasks like database imports or schema migrations, and they typically don't give you a ton of control over exactly what order things are applied in across multiple systems in a stack.
Puppet and Chef are examples of configuration management systems.
Deployment automation tools are for performing ad-hoc tasks. In other words, you run them explicitly when you need to do something. (Okay, sometimes you run them implicitly from a trigger, like from a continuous integration system.) These often orchestrate multiple systems in a predictable way; for example, you might only want one of your web servers to run a database migration during an upgrade, and you might want to do your app server upgrade only if the database migration succeeds, and you might want your app servers to restart three at a time so you don't bring down your whole application during the update. Most importantly, you only want this process to kick off exactly when you tell it to.
Capistrano and Fabric are popular examples of deployment automation tools. For single servers, you can just as easily use things like Makefiles all the way across your app.
In your particular case, you likely want a configuration management system handling things like the install of your database system and PHP, and the configuration of your web server. On the other hand, you likely want a deployment tool to handle the creation of your databases and the population of your test data into them. The download of your app code from Git can easily be modeled by either a configuration management or a deployment automation tool, depending on which suits your needs better. And regardless of which method you choose, people have differing opinions on how the config files for your application should make their way onto the server.
The most important thing when you're working with tools like these is that they're a complete waste if you're not using them correctly. In other words, if you're using a fancy automated deployment method to put your app on staging, and your production server doesn't actually look exactly like your fancy-pants staging server, you've blown a whole lot of effort for almost no gain. Do things right, and they'll serve you very well.