Collisionless shocks are ubiquitous in astrophysics. Besides their primary role of terminating supersonic flows, collisionless shocks are commonly inferred to accelerate nonthermal particles and cosmic rays, and to generate significant magnetic fields. How and if this actually happens remains largely a realm of speculations. I will present the results of a systematic study of relativistic collisionless shocks through ab-initio particle-in-cell simulations, focusing on the basic physics that mediates a shock. I will show how shock properties depend on magnetization and composition of the flow and describe which parameter regimes are conducive to particle acceleration. In particular, I will show the first evidence for self-consistent Fermi particle acceleration in simulations, and address the issue of the electron-ion temperature ratio in relativistic shocks. These simulations begin to place constraints on the composition and magnetization of relativistic outflows in astrophysics.