Heavy ion medical machine (HIMM) is built by the Institute of Modern Physics, Chinese Academy of Sciences, with a high-energy beam transport line with a height of 18 m, and its complex space mounting structure increases the difficulty of installation and alignment. The aim of this paper is to provide methods to install all accelerator components efficiently and to ensure that the alignment accuracies of all installed components are within the designed values. We accomplished the fiducialization and pre-alignment of complex modules by combining the laser tracker and the alignment telescope. By analyzing various elements that affect the accuracy of alignment, a method of alignment for high-energy beam transport line was proposed based on high-precision three-dimensional control network. All components have been installed and aligned in a short time, alignment position accuracy of magnets is less than 0.1 mm, and the treatment components alignment accuracy is no more than 0.4 mm. On the basis of error analysis, all alignment results are better than the required precisions, and all of these guaranteed the successful operation of HIMM.