First, this paper introduces the notion of L 0 -convex compactness for a special class of closed convex subsets-closed L 0 -convex subsets of a Hausdorff topological module over the topological algebra L 0 (F, K), where L 0 (F, K) is the algebra of equivalence classes of random variables from a probability space (Ω, F, P ) to the scalar field K of real numbers or complex numbers, endowed with the topology of convergence in probability. Then, this paper continues to develop the theory of L 0convex compactness by establishing various kinds of characterization theorems on L 0 -convex compactness for L 0 -convex subsets of a class of important topological modules-complete random normed modules, in particular, we make full use of the theory of random conjugate spaces to establish the characterization theorem of James type on L 0 -convex compactness for a closed L 0 -convex subset of a complete random normed module, which also surprisingly implies that our notion of L 0convex compactness coincides with GordanŽitković's notion of convex compactness in the context of a closed L 0 -convex subset of a complete random normed module. As the first application of our results, we give a fundamental theorem on random convex optimization (or, L 0 -convex optimization), which includes Hansen and Richard's famous result as a special case. As the second application, we give an existence theorem of solutions of random variational inequalities, which generalizes H.Brezis' classical result from a reflexive Banach space to a random reflexive complete random normed module. It should be emphasized that a new method, namely the L 0convex compactness method, is presented for the second application since the usual weak compactness method is no longer applicable in the present case. Besides, our fundamental theorem on random convex optimization can be also applied in the study of optimization problems of conditional convex risk measures, which will be given in our future papers.