Mounting PCB in extruded aluminum housing
Some extruded chassis have a built-in slot to hold a PCB, but there are many other methods. If you are only building a few, there are lots of options, if you are building huge quantities, you want the cost to be as low as possible.
For a hobbyist, threaded metal or plastic spacers are my favorite. There are also unthreaded spacers, then you use a long screw and put the nut on the inside of the box.
For larger quantity manufacturing, there are also snap-in plastic spacers. If you have ever opened a tower PC, the PCB motherboard was probably attached with snap-in mounts.

https://www.sparkfun.com/tutorials/38