Context. The XMM-Large Scale Structure survey, covering an area of 11.1 sq. deg., contains more than 6000 X-ray point-like sources detected with the XMM-Newton to a flux of 3 × 10 −15 erg s −1 cm −2 in the [0.5−2] keV band. The vast majority of these sources have optical (CFHTLS), infrared (SWIRE IRAC and MIPS), near-infrared (UKIDSS), and/or ultraviolet (GALEX) counterparts. Aims. We wish to investigate the environmental properties of the different types of the XMM-LSS X-ray sources by defining their environment using the i -band CFHTLS W1 catalog of optical galaxies to a magnitude limit of 23.5 mag. Methods. We have classified 4435 X-ray selected sources on the basis of their spectra, SEDs, and X-ray luminosity, and estimated their photometric redshifts, which have a 4−11 band photometry with an accuracy of σ z/(1+zsp) = 0.076 with 22.6% outliers for i < 26 mag. We estimated the local overdensities of 777 X-ray sources that have spectro-z or photo-z calculated by using more than seven bands (accuracy of σ z/(1+zsp) = 0.061 with 13.8% outliers) within the volume-limited region defined by 0.1 ≤ z ≤ 0.85 and −23.5 < M i < −20. Results. Although X-ray sources may be found in variety of environments, a high fraction ( > ∼ 55−60%), as verified by comparing with the random expectations, reside in overdense regions. The galaxy overdensities within which X-ray sources reside show a positive recent redshift evolution (at least for the range studied; z < ∼ 0.85). We also find that X-ray selected galaxies, when compared to AGN, inhabit significantly higher galaxy overdensities, although their spatial extent appear to be smaller than that of AGN. Hard AGN (HR ≥ −0.2) are located in more overdense regions than soft AGN (HR < −0.2), which is clearly seen in both redshift ranges, although it appears to be stronger in the higher redshift range (0.55 < z < 0.85). Furthermore, the galaxy overdensities (with δ > ∼ 1.5) within which soft AGN are embedded appear to evolve more rapidly compared to the corresponding overdensities around hard AGN.