Atom chips are a promising candidate for a scalable architecture for quantum information processing provided a universal set of gates can be implemented with high fidelity. The difficult part in achieving universality is the entangling two-qubit gate. We consider a Rydberg phase gate for two atoms trapped on a chip and employ optimal control theory to find the shortest gate that still yields a reasonable gate error. Our parameters correspond to a situation where the Rydberg blockade regime is not yet reached. We discuss the role of spontaneous emission and the effect of noise from the chip surface on the atoms in the Rydberg state.