A general form of the photon position operator with commuting components fulfilling some natural axioms is obtained. This operator commutes with the photon helicity operator, is Hermitian with respect to the Bia\l{}ynicki--Birula scalar product, and is defined up to a unitary transformation preserving the transversality condition. It is shown that, using the procedure analogous to the one introduced by T. T. Wu and C. N. Yang for the case of the Dirac magnetic monopole, the photon position operator can be defined by a flat connection in some trivial vector bundle over ${\mathbb{R}}^{3}\ensuremath{\setminus}{(0,0,0)}$. This observation enables us to reformulate the quantum mechanics of a single photon on $({\mathbb{R}}^{3}\ensuremath{\setminus}{(0,0,0)})\ifmmode\times\else\texttimes\fi{}{\mathbb{C}}^{2}$.