We discuss a method to solve models with long-range interactions in the microcanonical and canonical ensemble. The method closely follows the one introduced by R.S. Ellis, Physica D 133, 106 (1999), which uses large deviation techniques. We show how it can be adapted to obtain the solution of a large class of simple models, which can show ensemble inequivalence. The model Hamiltonian can have both discrete (Ising, Potts) and continuous (HMF, Free Electron Laser) state variables. This latter extension gives access to the comparison with dynamics and to the study of non-equilibrium effects. We treat both infinite range and slowly decreasing interactions and, in particular, we present the solution of the α-Ising model in one-dimension with 0 ≤ α < 1. Keywords: Long-range interactions, Large deviation techniques, Mean-field limit.PACS numbers: 05.20.-y Classical statistical mechanics A system with long-range interactions is characterized by an interparticle potential V (r) which decreases at large distances r slower than a power r −α with α < d, d being the dimension of the embedding space [1]. Classical examples are self-gravitating [2] and Coulomb [3] systems, vortices in two-dimensional fluid mechanics [4], waveparticles interaction [5,6] and trapped charged particles [7]. The behaviour of such systems is interesting both from the dynamical point of view, because they display peculiar quasi-stationary states that are related to the underlying Vlasov equations [8], and from the static point of view, because equilibrium statistical mechanics shows new types of phase transitions and cases of ensemble inequivalence [9]. In this paper we will restrict ourselves to the second aspect.In long-range interacting systems, essentially all the particles contribute to the local field: the fluctuations around the mean value are small because of the law of large numbers. This explains qualitatively why the mean-field scaling, which amounts to let the number of particles go to infinity at fixed volume [10,11], is usually extremely good. However, let us remind that for long-range interacting systems, microcanonical and canonical ensembles are not necessarily equivalent in the mean-field limit [12,13,14]. Moreover, because of the non additivity of the energy, the usual construction of the canonical ensemble cannot be applied. This is the reason why the microcanonical ensemble is considered by some authors [2,15] as the only "physically motivated" one. Hence, it is extremely important to develop rigorous techniques to solve non trivial physical models in the microcanonical ensemble. One finds in books the solution for the perfect gas, but generalizations to interacting particle systems are difficult.The goal of this paper is to advocate the use of large deviation techniques as a tool to explicitly derive microcanonical and canonical equilibrium solutions for a wide class of models. As a first step in this direction, we will discuss here a general solution method to treat in full detail mean-field models without short distance singu...