Testing Magento With PHP 5.3 Using XAMPP
by Kyle on · Posted in Howto
Want More PHP Tricks?
Check out Code Snips, our public source code repository.
With our recent announcement about upgrading from PHP 5.2 to PHP 5.3 on our servers starting July 2011, we’ve decided to put up a tutorial on how to test your site locally to make sure it will be compatible.
Jump To Section
Setting Up XAMPP
The first thing you’ll need is XAMPP, which is available for free on the following operating systems:
XAMPP includes everything you’ll need to test your application as well:
- Apache 2.2.17
- MySQL 5.3.8
- PHP 5.3.5
- phpMyAdmin 3.3.9
For this tutorial, we’ll be running XAMPP on Windows 7, and we’ll use the installer version as well.
Once you have downloaded XAMPP, run the installer. You’ll be asked to select a location to install XAMPP. Just leave it as is and continue.
Next, you’ll be asked if you want to setup Apache, MySQL, and FTP as a server. Go ahead and put a checkmark for Apache and MySQL.
Now XAMPP will start installing, which will take a couple minutes. If you get an error about Apache not being able to start because port 80 and 443 are in use, here’s how to fix this:
Open up the command prompt by going to the Start menu and clicking on Run (you can also hit the Windows + R on your keyboard). Type cmd and hit OK.
When the command prompt is up, type the following command and hit the Enter key:
netstat -ano
Under the Foreign Address column, look for an IP address followed by :80 (the port that Apache needs to use). When you find it, take note of the PID (last column), then type the following command and hit the Enter key:
tasklist
You should be able to match up the PID with the application that is running this. In our case, Skype was using this port.
To fix this, open up Skype, and click on Tools and then Options. Under the Advanced section, click on Connections. Uncheck the box next to Use port 80 and 443 as alternatives for incoming connections. Click the Save button and then restart Skype. Now when you run the netstat command, you shouldn’t see anything with :80 after it.
Open up the XAMPP Control Panel Application (this started after you finished installing XAMPP, and if it’s not open, it should be in the taskbar) and put a checkmark next to Svc for the Apache section. Click OK when it asks if you’d like to install this as a service. Then click on the Start button and wait for Apache to start.
Now that everything is setup, you can open up your browser and go to the following address:
http://127.0.0.1/
You will see the XAMPP welcome screen once the page loads. Go ahead and click on your preferred language to get to the web-based control panel. From here, you can view the status of your services, a PHP info file, Perl info file, and the link to phpMyAdmin.
Assuming you installed XAMPP in the default location, the document root will be:
C:\xampp\htdocs
You can delete everything in this directory if you want.
Setting Up Magento
Other Applications
With XAMPP setup, you can test out any application now, such as WordPress, vBulletin, Drupal, ExpressionEngine, etc.
So let’s say we want to bring our Magento site over to our local computer to test. Here’s how we would do this:
Go ahead and make a directory in your document root and name it your domain name. We’ll set our folder name to magentocontainers.com, since that’s the test site we’re going to bring over (we will also reference this folder name throughout the install, so adjust accordingly). The URL to access this directory will be:
http://127.0.0.1/magentocontainers.com/
So now we need to grab our Magento files and database from our website. To do this, you can use SSH to archive your site, and the mysqldump command to export your database, or you can use the backup feature cPanel to do this. We’ll just use cPanel to make this easier.
Database Size
If your database is extremely large, consider cleaning up the database on the server first before downloading a backup.
Open up cPanel for your domain and click on the Backup Wizard icon. Click the Backup link on the left, then the Home Directory link. Now click the Home Directory button and save the file to your computer. Click the Go Back link and select the MySQL Databases link. Click on the database name that Magento is using and save that to your computer as well.
Once your home directory and database backup has finished, you’ll need to open them up and extract the files. We’ll start with the home directory backup.
Keep browsing deeper in the file structure until you’re in the public_html folder. Select all of the files and extract them to the directory we created previously.
Now open up the database backup and extract the .sql file to the following location:
C:\xampp\mysql\bin
Go ahead and rename it to data.sql. Once the file has been copied, go to phpMyAdmin:
http://127.0.0.1/phpmyadmin/
Under Create new database on the front page, enter a name for your database and click the Create button. We’re going to call our database magento. Open up the command prompt again and enter te following commands:
cd C:\xampp\mysql\bin
mysql -u root magento < data.sql
Be patient while this runs, as it could take a while if the .sql file is really large.
Once it finishes, you need to open up the following file and change the database information:
C:\xampp\htdocs\magentocontainers.com\app\etc
You will use the following values:
<host><![CDATA[localhost]]></host>
<username><![CDATA[root]]></username>
<password><![CDATA[]]></password>
<dbname><![CDATA[magento]]></dbname>
<active>1</active>
Save that file and go back to phpMyAdmin. Select the magento database from the left, and click on the SQL tab. Run the following:
SELECT * FROM `core_config_data` WHERE `path` LIKE '%base_url%';
You will need to change these values to the local address so you can access your site. We will change ours to the following:
http://127.0.0.1/magentocontainers.com/
Now open up the following folder and delete the cache and session folders:
C:\xampp\htdocs\magentocontainers.com\var
And that should do it! Just open up your local site in your browser and start testing to see if anything is broken.
![]()