We investigate the chiral phase transition in the soft-wall model of AdS/QCD at zero chemical potential for two-flavor and three-flavor cases, respectively. We show that there is no spontaneous chiral symmetry breaking in the original soft-wall model. After detailed analysis, we find that in order to realize chiral symmetry breaking and restoration, both profiles for the scalar potential and the dilaton field are essential. The scalar potential determines the possible solution structure of the chiral condensate, except the mass term, it takes another quartic term for the two-flavor case, and for the three-flavor case, one has to take into account an extra cubic term due to the t'Hooft determinant interaction. The profile of the dilaton field reflects the gluodynamics, which is negative at a certain ultraviolet scale and approaches positive quadratic behavior at far infrared region. With this set-up, the spontaneous chiral symmetry breaking in the vacuum and its restoration at finite temperature can be realized perfectly. In the two-flavor case, it gives a second order chiral phase transition in the chiral limit, while the transition turns to be a crossover for any finite quark mass. In the case of three-flavor, the phase transition becomes a first order one in the chiral limit, while above sufficient large quark mass it turns to be a crossover again. This scenario agrees exactly with the current understanding on chiral phase transition from lattice QCD and other effective model studies.