A generalization of the classical Caffarelli–Kohn–Nirenberg inequality is obtained in the setting of Orlicz–Sobolev spaces. As applications, we prove a compact embedding result, and we establish the existence of weak solutions of the Dirichlet problem for a nonhomogeneous and degenerate/singular elliptic PDE.