This paper proposes a practical modelling solution to the problem of sharing distributed renewable electricity generation in the context of renewable energy communities. According to this approach, the economic benefits of community members, derived from their participation in the community, are shared by means of repartition keys, which represent the proportion of total local electricity to be allocated, ex-post, to each community member. These keys are computed through a centralised optimisation framework that optimally allocates the electricity generated within the community (i.e., local electricity) among the community members so as to minimise the sum of the electricity bills of all community members.