In recent years, there has been heightened interest in quantum teleportation, which allows for the transfer of unknown quantum states over arbitrary distances. Quantum teleportation not only serves as an essential ingredient in long-distance quantum communication, but also provides enabling technologies for practical quantum computation. Of particular interest is the scheme proposed by D. Gottesman and I. L. Chuang [(1999) Nature 402:390-393], showing that quantum gates can be implemented by teleporting qubits with the help of some special entangled states. Therefore, the construction of a quantum computer can be simply based on some multiparticle entangled states, Bell-state measurements, and single-qubit operations. The feasibility of this scheme relaxes experimental constraints on realizing universal quantum computation. Using two different methods, we demonstrate the smallest nontrivial module in such a scheme--a teleportation-based quantum entangling gate for two different photonic qubits. One uses a high-fidelity six-photon interferometer to realize controlled-NOT gates, and the other uses four-photon hyperentanglement to realize controlled-Phase gates. The results clearly demonstrate the working principles and the entangling capability of the gates. Our experiment represents an important step toward the realization of practical quantum computers and could lead to many further applications in linear optics quantum information processing.