Share it

Bookmark and Share

Translate

Thursday, August 16, 2012

0 Avoid Two Problems Installing Magento On A Localhost

Magento Commerce’s open source and free Community Edition is one of the most popular ecommerce platforms available today, and web designers and developers that specialize in working with Magento are finding the platform to be very lucrative.
But if, like many developers, you like to build your websites, templates, and applications on a localhost, there are at least two gotchas that can mess up your local installation.
In this tutorial, I’ll quickly walk you through the Magento installation process for WAMP, pointing out two spots where you could avoid trouble with a little foreknowledge.

Before You Install Magento

I would be remiss not to first review Magento’s system requirements, before jumping into the installation process, so here they are:
  • Linux, Windows, or another UNIX-compatible operating system;
  • Apache Web Server 1.x or 2.x;
  • PHP 5.2.0 or newer, and a number of extensions including PDO/MySQL, MySQLi, mcrypt, mhash, curl, mhash, simplexml, and DOM;
  • MySQL 4.1.20 or newer;
  • A Sendmail-compatible Mail Transfer Agent (MTA).

Step 1: Download The Latest Version of Magento

When downloading the Community Edition of Magento from the Magento downloads page, you’re presented with three choices: (1) you can get the Downloader, which will load files as you install, (2) you can choose the Full Release, which will include about 10,085 items and something like 44.5 MB, or (3) you can download a Preview Release of the forthcoming version of the platform, which may have some new features, but will presumably be less stable.
For this tutorial, I am going to download the Full Release as a .zip. There is also sample data that you can download if you want to have some sample products in your store.

Step 2: Extend PHP

If you’re like me, you read those system requirements, saw PHP 5.2.0 and thought, “I’m good.” But the devil is in the details. By default WAMP comments out three of the extensions you’ll need for Magento. To avoid a problem later you need to adjust (remove a semicolon from) three lines of identical code in two separate php.ini files.
First, locate the php.ini file in the Apache folder on WAMP. The path should be wamp/bin/apache/Apache2.x.x/bin. In my version of the php.ini file, the first change is at line 662. Even if things change for the version you’re using, that line number should put you in the proper neighborhood. By default, that line reads:

;extension=php_curl.dll
You want to remove the semicolon resulting in: extension=php_curl.dll.
Next move down to line 675 and locate:

;extension=php_mcrypt.dll
Again remove the semicolon, and then head to line 688 and look for:

;extension=phppdomysql.dll
You guessed it, remove the semicolon.
Now repeat this process for the php.ini file in your PHP folder. The path should be wamp/bin/php/php5.2.9-2, and the line numbers should be exactly the same.
You’ll need to restart WAMP for these changes to take effect. So do that now and get ready to install Magento.

Step 3: Create a Folder for Magento on WAMP

In the “www” folder in WAMP, create a new folder for Magento. Next, extract all of the Magento files you download from the .zip file and place them in your new Magento folder. This process could take a few minutes, since, as I mentioned above, you’re copying approximately 44.5 MB.

Step 4: Avoid the Cookie Problem

The second potential problem you’ll face when you install Magento on your localhost has to do with cookies. The Magento platform uses them, and most browsers won’t accept them from the localhost. If left unchanged, you’ll get many errors and no error messages.
You have a couple of choices here, you can create another entry in your /etc/hosts file and use it to access Magento or you can comment out some of the cookie settings.
To comment out session cookies, you’ll need to navigate through your recently copied Magento folders to reach Varien.php. The path is app/code/core/Mage/Core/Model/Session/Abstract.
Find the code for setting session cookie parameters. In my copy of the Varien.php file, these started on line 77. Here is the specific code for which you’re looking:
  1. <code>
  2.         // set session cookie params
  3.         session_set_cookie_params(
  4.             $this->getCookie()->getLifetime(),
  5.             $this->getCookie()->getPath(),
  6.             $this->getCookie()->getDomain(),
  7.             $this->getCookie()->isSecure(),
  8.             $this->getCookie()->getHttponly()
  9. </code>
Comment out the final three lines and be sure to remove the comma after $this->getCookie()->getPath(). You should end up with this:
  1. <code>
  2.         // set session cookie params
  3.         session_set_cookie_params(
  4.             $this->getCookie()->getLifetime(),
  5.             $this->getCookie()->getPath()
  6.             // $this->getCookie()->getDomain(),
  7.             // $this->getCookie()->isSecure(),
  8.             // $this->getCookie()->getHttponly()
  9. </code>
With your second potential problem averted, the installation should be straightforward from here.

Step 5: Create A Database

Navigate to the localhost, select myphpadmin and create a database.

Step 6: Start Up the Installation Wizard

Navigate to your Magento folder in WAMP in your browser and the Magento installation wizard should start up. You’ll be asked to fill out a few simple fields and connect to the database you created in Step 5.
Don’t be surprised if it takes Magento a little while to generate the required database tables, as there were 218 of them in the version I downloaded.
You’ll need to set your preferences for location, time, and currency. You’ll also need to establish an administrator account, and make some choices about whether or not to have Apache rewrite your URLs for better search engine optimization.

Summing Up

Even experienced developers could get hung up installing Magento on a localhost because of a couple of extra steps required for a clean and functioning installation. In this tutorial, I quickly walked you through the process of installing Magento on WAMP, all the while pointing out the two main “gotchas” that could spoil your easy installation.


0 comments:

Post a Comment

Thanks for your valuable Comment

 

TechnoTipworld- Tips,Tricks,Technology Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates