In this work, the effect of p-type doping on the structural, electronic, and optical properties of AlxGa1-xAs nanowires are investigated by first-principles calculations. Different doping elements (Be, Mg, Zn), doping methods (interstitial and substitution doping) and doping concentration are considered. The calculations of formation energy suggest that the structural stability of p-type AlxGa1-xAs nanowires is gradually weaken as the rise of doping concentration and Al composition. Besides, the difficulty of forming substitution doping for different doping elements obeys the following order: Be<Mg<Zn. In addition, the substitution doping atom tends to replace Ga atom rather than Al atom to form substitution doping structure. After substitution doping, all energy bands shift to higher energy region due to the orbital hybridization of electronic states induced by impurity atom and nanowire atoms. Moreover, the substitution doping leads to the Fermi level entering into the valence band, resulting in obviously p-type conductivity. The p-type modulation doping is indeed effective in the axial type AlxGa1-xAs nanowires with p-type carrier concentration varying between 1.85×1020 cm-3 and 4.42×1020 cm-3, and the conductivity will be further enhanced with increasing substitution doping concentration or Al composition. Finally, the optical absorption of AlxGa1-xAs nanowire photocathodes can be effectively enhanced through BeGa doping. Our findings not only present a comprehensive understanding of p-type doping mechanism of AlxGa1-xAs nanowires, but also provide a theoretical basis for preparing AlxGa1-xAs nanowire based photoelectric devices with p-type properties.