The electronic and magnetic properties of ZnO nanowires doped with one and two Fe atoms are comparatively studied in terms of the first-principles calculation. The formation energies of doped nanowires are smaller than those of the pristine ones, indicating that the doping process is an exothermic reaction. The result shows that Fe atom prefers to the surface position. The magnetic moments are mainly contributed by the Fe-3d orbital. Due to the hybridization interaction, a small magnetic moment is also induced in nearest neighboring O atoms. The magnetic moments of the Fe and O atoms have the same direction, indicating ferromagnetic coupling between them. Surface doped nanowire is semiconductor, while middle doped nanowire is half-metalic, which have important applications in spintronics.