Configurations in abelian categories. II. Moduli stacks