Before we start writing PHP code, it is good to install XAMPP package from Apache Friends. XAMPP is a full-featured AMPP (Apache, MySQL, PHP, Perl) and a non-commercial middleware stacks available on Linux. After installation, you can use your local PC or laptop to run web bot or spider scripts, or even test out a full-featured product site, such as Joomla or Wordpress before upload to live server.
XAMPP is very stable and you can run screen scraping scripts for weeks from your PC without problems, assuming your scripts are clean, no memory leak etc. Domain name and web hosting are not needed to run your PHP/MySQL program on XAMPP. Sometimes you do not even need internet access during script writing.
Assuming you are using Windows PC, you can download the latest XAMPP from Apache Friends or get older versions at SourceForge. Each version of XAMPP contains different versions of Apache, MySQl and PHP. One simple way to select XAMPP version is to match as close as possible the PHP version of your live server. Example, my server is using PHP 5.3.x, so I pick XAMPP 1.7.7 to download. If your server is currently using PHP 5.4.x, then you can download XAMPP 1.8.x with close match to your PHP version.
If you go to SourceForge, you can see a list of XAMPP package. For this article, I downloaded xampp-win32-1.7.7-VC9-installer.exe (84.9Mb) and double click to start installation process.
You should have the first pop-up requesting you to select a language. Click OK.
There should be a warning message after that. Click OK.
Now XAMPP Setup Wizard is displayed. Click Next.
Install XAMPP at C:\xampp, so click Next.
Follow the default setup, so click Install.
Then you will see files installation in progress. It will take a while.
Before the end of the process, a message box pop up. It will disappear soon.
Now installation process completed. Click Finish.
Click Yes to start XAMPP control panel.
To start using PHP/MySQL from your PC, click the "Start" button of Apache and MySql.
The buttons change to "Stop" with "Running" next to them. Your XAMPP is ready to use.
Before we start writing code for web spiders, we need additional extension. Go to C:\xampp\php and open up php.ini file to edit.
Find this line:
;extension=php_curl.dll
uncomment it (remove ";" in front) and save.
We need to use cURL extension later. You need to restart XAMPP by clicking "Stop" buttons for PHP and MySQL at control panel, then press "Start" again.
We are almost ready!! :)