In this paper, an optimal wireless resources allocation scheme is put forward to improve the performance for both cellular and Device-to-Device (D2D) users in a hybrid network. The resource unit and power allocation can be modeled into a sum-rate optimization problem with the constraint of power limitation and rate ratio. The rate ratio is used to measure the data rate requirements from both cellular and D2D users. By using the Lagrange Multiplier Method, we derived out the optimal formula about allocating the power and resource unit for both cellular and D2D users. According to the optimal formula, the relationship between the transmission power and resource unit allocation is mutually conditional. Then the resource allocation scheme algorithm was given. And the power allocation can be resolved by the water-filling algorithm. Simulation results show that the proposed scheme improves the sum-throughput significantly as well as the fairness.