Just follow the instructions I linked to, and program the ESP8266 using the FTDI chip. Then connect the ESP to the Mega.
The replies you keep posting just indicate that you didn't even go through the effort of reading the information I provided.
Pieter