Recently, I wiped my main drive to do a completely fresh installation of OSX. I have a site that I work on for a client that uses Magento as the content management system (www.chouchoute.co.uk) and for development purposes, I set up a mirror of the site on my localhost. I use MAMP for local development, but WAMP (Windows) or LAMP (Linux) will do just as well. You need a working system to proceed…
This post is a much more comprehensive version of an earlier post on Setting up Magento on OSX.
Magento is a hugely-complex CMS, and for clients with a small product range, it may be a bit like buying a sportscar just to drive to the corner shops. It is however, extremely powerful and is the chosen CMS of many companies. Setting it up is a long way from WordPress’ Famous 5-Minute Install, a very long way and is not an easy thing for novices. That said, there are some incredibly helpful people who post a lot of sound advice in the Magento forums.
Before you get started, you may want to download and install the Magento Demo Store, just so you can see how everything is working, and also to use as a base template for building new skins for your site. Head over to the Magento site and download both the latest stable release (220.127.116.11 at the time of writing) and the sample store database (sample data). Move the downloaded folder to your htdocs or Sites folder and rename it to magento. You need to create a database (name it magento for simplicity) and import the sample data into it before installing the CMS itself. Using an FTP client, set the permissions on the downloaded magento site folder to 777. Now navigate in your browser to http://localhost/magento to start the installation by running the wizard. When you get to the Database connection panel, for the database name, make sure you call it magento, or whatever you named it earlier, adding any usernames and passwords you have set. Once the setup is complete, you can view the frontend store at http://localhost/magento or the backend at http://localhost/magento/admin where you can customise your site.
Once you have a working installation of Magento, you can proceed to setting up a local mirror of your live site. All the steps I explain here are based on your site running from the Sites folder. You may need to amend things to suit your environment.
- You will need FTP access to your remote site. Create a folder called mysite (change this for your own site name) in the Sites folder. Download the entire site from the root directory on the remote server to the mysite folder, and make sure the permissions on this are 777.
- Log in to the admin area on the remote site, and go to System > Tools > Backups to create a dump file of the live site. Download this and create a new database in phpMyAdmin on your localhost.
- Expand the .tar.bz2 file and import the sql dump into your database. If you have a lot of data in the file, you might find it easier to open the file as plain text and manually split the data across several files named dump1.sql, dump2.sql etc.
- I have found that to get a Magento site working on a local server, you need to use Virtual Hosts. Open your private/etc/hosts file and edit it to look something like this:##
# Host Database
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
# my websites
- You also need to edit the mysite > app > etc >local.xml file so it reflects your username/password and database name.
- Finally, go into phpMyAdmin and your site’s database, looking for the core_config_data table. There are a couple of fields you need to edit so the urls match your http://localhost/mysite/ but make sure you have the trailing slash on the site path.
These tell the database where to point your links between pages and content.
This should be all you need to view your local mirror site, just restart MAMP and enter the http://localhost/mysite address in your browser.
In some cases (if you are running PHP 5.3) you might see an error like this:
Fatal error: Method Varien_Object::__tostring() cannot take arguments in /magento/lib/Varien/Object.php
This post on the Learn Magento blog explains how to fix this.
As a parting tip, it is often useful when working on both live and local sites to use different favicons to identify which tab is which! You are welcome to download this one and put it in your root folder, and also in your skin > frontend >default > skinname folder:
Enjoy!Magento Apple, Dynamic websites, file paths, preferences, settings, Web design, Website designer