Connect them as showed in http://techrm.blogspot.it/2012/12/how-to-interface-arduino-mega-2560-to.html
In this example I use ArduinoIDE version 0021.
Follow the instructions about the setting of the WiShield library.
Now connect a 470 ohm resistor and a led in series between pin 12 and pin gnd of the Arduino, as shown below:
Now you need to download two applications from https://github.com/rickit69/techrm:
1) test_arduino, a simple php application
2) test_my_server, a simple sketch.
Put the folder test_arduino in the documents folder of your Apache server (for Linux it could be /var/www/html/). Put the test_my_server folder in the sketchbook of your Arduino IDE.
In the test_my_server.pde file modify the wireless parameters (ip address, subnet mask, gateway, SSID, security type, WPA/WPA2 passphrase or WEP keys) according to your wireless network parameters.
Compile the sketch and load to the Arduino.
Now go in the folder test_arduino and, in the test.php and test_controller.php files, modify the ip address (in the example it is 192.168.0.3) according to the ip address in the test_my_server.pde.
Open a browser and go to the URL http://localhost/test_arduino/test.php.
You'll see a web page with a form with 2 buttons. One button is to turn on the led, the other one is to turn it off.
The sketch test_my_server receives the commands from the php app test_arduino and then turns on/off the led.
The video below shows you the application running: