We study the extremal parameter N(n, m, H) which is the largest number of copies of a hypergraph H that can be formed of at most n vertices and m edges. Generalizing previous work of Alon [1], Friedgut and Kahn [6] and Janson, Oleszkiewicz and the third author [10], we obtain an asymptotic formula for N(n, m, H) which is strongly related to the solution αq(H) of a linear programming problem, called here the fractional q-independence number of H. We observe that αq(H) is a piecewise linear function of q and determine it explicitly for some ranges of q and some classes of H. As an application, we derive exponential bounds on the upper tail of the distribution of the number of copies of H in a random hypergraph.