We review the physics of relativistic shocks, which are often invoked as the sources of non-thermal particles in pulsar wind nebulae (PWNe), gamma-ray bursts (GRBs), and active galactic nuclei (AGN) jets, and as possible sources of ultra-high energy cosmic-rays. We focus on particle acceleration and magnetic field generation, and describe the recent progress in the field driven by theory advances and by the rapid development of particle-in-cell (PIC) simulations. In weakly magnetized or quasi parallel-shocks (i.e. where the magnetic field is nearly aligned with the flow), particle acceleration is efficient. The accelerated particles stream ahead of the shock, where they generate strong magnetic waves which in turn scatter the particles back and forth across the shock, mediating their acceleration. In contrast, in strongly magnetized quasi-perpendicular shocks, the efficiencies of both particle acceleration and magnetic field generation are suppressed. Particle acceleration, when efficient, modifies the turbulence around the shock on a long time scale, and the accelerated particles have a characteristic energy spectral index of s γ 2.2 in the ultra-relativistic limit. We discuss how this novel understanding of particle acceleration and magnetic field generation in relativistic shocks can be applied to high-energy astrophysical phenomena, with an emphasis on PWNe and GRB afterglows.All authors contributed equally to this review.