We demonstrate the growth of phosphorus doped Zn 1-x Mg x O nanowire (NW) using pulsed laser deposition. For the first time, p-type Zn 0.92 Mg 0.08 O:P NWs are likely obtained in reference to atomic force microscopy based piezoelectric output measurements, X-ray photoelectron spectroscopy, and the transport property between the NWs and a n-type ZnO film. A shallow acceptor level of ∼140 meV is identified by temperaturedependent photoluminescence. A piezoelectric output of 60 mV on average has been received using the doped NWs. Besides a control on NW aspect ratio and density, band gap engineering has also been achieved by alloying with Mg to a content of x ) 0.23. The alloyed NWs with controllable conductivity type have potential application in high-efficiency all-ZnO NWs based LED, high-output ZnO nanogenerator, and other optical or electrical devices.