The Shulchan Aruch in the beginning of Orach Chaim (1, 3) says that one should mourn over the "Churban", the destruction of the Beis Hamikdash. The Mishna Berura says in the name of the mekubalim that this is referring to rising at "Chatzos", midnight, to recite Tikun Chatzos. Yesod Veshoresh Ha'Avodah (2:5-6) among others speaks at length about the importance of reciting Tikun Chatzos. Reb Nachman of Breslov says that the main devotion of a Jew is to get up at Chatzos (Sichos Haran 301) and that this "sweetens" harsh judgments (Likutei Mohoran 149).
Tikun Rachel and Tikun Leah
Tikun Chatzos consists of two parts; Tikun Rachel and Tikun Leah. Tikun Rachel's main theme is mourning over the Churban. It consists of Viduy, Tehilim 137 and 79, the last chapter of Eicha, select verses from Nach and 5 Kinos (the Sephardi Siddurim do not have the Kinnos). Tikun Leah consists mainly of chapters of Tehilim praising and yearning for Hashem. The chapters of Tehilim are 24, 42, 43, 20, 67, 111, 51, 126. There are also a few additional verses and a short prayer to return the Beis Hamikdash (as said in Yom Tov Mussaf). Some siddurim include a Kinah from Rav Chaim HaKohen of Aram Soba. After, the custom is to learn the first chapter of Mishnayos Tamid, which is printed at the end of Tikun Chatzos.
There are various customs pertaining to when the different parts are said. (I will list the way I am familiar with.) On days when "Tachnun" is not recited, Tikun Rachel and Tehilim 20 and 51 from Tikun Leah aren't said. Other times both are recited. On Tish B'Av night, only Tikun Rachel is said.
There are many customs associated with Tikun Chatzos, such sitting on the floor in the doorway, taking off the shoes and putting ashes on the head, in the place of the Tefilin. Although these are hallowed customs done as signs of mourning, they are not actual requirements. The most important part is the recital.
Some say the time of chatzos at night is 12 hours after the chatzos of day. Rav Nachman (and the Magen Avrohom based on Zohar) insists that it is always 6 hours after nightfall and lasts for 2 hours or until daybreak, if that comes first. (Regular hours not adjusted hours. If night fall is 6:00PM, chatzos is 12:00AM; If nightfall is 9:00PM, chatzos is 3:00AM.) If necessary, it may be recited anytime up till daybreak.
If one woke up to say Tikun Chatzos he needs to recite many of the morning blessings. There are different customs and may depend on whether or not one will go back to sleep. Speak to a qualified Rabbi who will advise you in this matter.
Bein Hamitzarim – "The Three Weeks"
The Arizal says that after midday during "three weeks" one should mourn over the destruction of the Beis Hamikdash. (Baer Hetiv 551:40; Mishna Berura 551:103; Kaf Hachaim 551:121; Yesod Veshoresh Ha'Avodah 9:11) The Kaf Hachaim says this is accomplished by saying the Tikun Rachel section of Tikun Chatzos, which is the general custom. This custom of reciting Tikun Chatzos by day during "the three weeks" is kept by many communities. In the Yeshiva of the Chasam Sofer they would say it together "bitzibur". There are places in Eretz Yisroel and the Diaspora where this is done today. Many who do not recite it the rest of the year do so during the three weeks.
Tikun Chatzos for All
The Noda BeYehuda, in his days, lamented the fact that Tikun Chatzos had fallen out of favor in his times. He said that first thing for scholars and average people to do is to shed tears over the Churban. He says that reciting Tikun Chatzos destroys the klipos of the wicked people that cause the lengthening of the golus. People think that this is only for the tzadikim and mekubalim, but it is incumbent on all of Klal Yisroel to mourn over the churban, each on their own level. As Reb Nachman says, "the main devotion of a Jew is Tikun Chatzos." (Sichos Haran 301). The Shelah Hakodosh says that "one who regularly gets up for Tikun Chatzos is a Tzadik".
Tikun Chatzos used to be found at the beginning of almost every siddur; that was how a Jew started his day. Although you won't find it in the typical "Nusach Sfard" siddur of today, it can be found in most "Chassidishe siddurim". It is also in the "Rav Yaakov Emden" siddur, the Siddur HaGra (there are many versions; the ones I've seen have it.) and the Sephardi siddurim (albeit without the kinos, as per their custom). There is a great version available with full Hebrew text, English translation and several fascinating chapters discussing Tikun Chatzos, titled The Sweetest Hour. (I highly recommend this. I often use this.)
Some say that women do not recite Tikun Chatzos, but others say that a G-d fearing woman may do so.
If one is not accustomed to saying Tikun Chatzos, it may seem like a big undertaking. Many great Rabbonim have suggested that one who can't recite it all, should take one or two chapters of Tehilim from each part and say it. If you're up to it, you can recite another chapter or kinah. The main thing is to think about the destruction of the Beis Hamikdash and how it's been so many years that Hashem does not have His House, so to speak. If one can't do it every night then it can be done whenever one is able to. Better a little than nothing. But how can we go without increasing, at least slightly, our mourning and yearning for the Beis Hamikdash.
I know many, including myself, can't really feel the loss of the Beis Hamikdash. The solution is to ask Hashem to help us feel the loss and the desire for the rebuilding of the Beis Hamikdash. Surely, that is a prayer that will find favor in the Eyes of Hashem. Remember, by saying Tikun Chatzos we are mourning over the Churban, and the Gemara (Taanis 30b) says: כל המתאבל על ירושלים זוכה ורואה בשמחתה "Whoever mourns for Yerushalaim, will merit and see it (rebuilt) in its happiness". May we see it happen speedily in our days. Amen!