We introduce a new technique to optimize a linear cost function subject to an affine homogeneous quadratic integral inequality, i.e., the requirement that a homogeneous quadratic integral functional affine in the optimization variables is nonnegative over a space of functions defined by homogeneous boundary conditions. Such problems arise in control and stability or input-to-state/output analysis of systems governed by partial differential equations (PDEs), particularly fluid dynamical systems. We derive outer approximations for the feasible set of a homogeneous quadratic integral inequality in terms of linear matrix inequalities (LMIs), and show that a convergent sequence of lower bounds for the optimal cost can be computed with a sequence of semidefinite programs (SDPs). We also obtain inner approximations in terms of LMIs and sum-of-squares constraints, so upper bounds for the optimal cost and strictly feasible points for the integral inequality can be computed with SDPs. We present QUINOPT, an open-source add-on to YALMIP to aid the formulation and solution of our SDPs, and demonstrate our techniques on problems arising from the stability analysis of PDEs.