Quasialigned, single-crystal Zn1-xMgxO (x=0-0.32) nanorods were synthesized on Si substrates by thermal evaporation. Zn1-xMgxO nanorods grew along the  crystal direction and had uniform hexagonal planes with diameters of 420-120 nm. The predominant ultraviolet luminescence could be tuned from 379 (x=0) to 305 nm (x=0.32) at room temperature. This blueshift indicated the band gap engineering in Zn1-xMgxO nanorods. Temperature-dependent photoluminescence was used to illustrate the free-exciton emission from Zn1-xMgxO nanorods. The exciton binding energy decreased from 59 (x=0) to 49 meV (x=0.18) and then increased to 54 meV (x=0.32).