Magento: moving a store to another server

Tuesday, June 16. 2009
Comments

Frequently, you do client work and if you are fortunate enough, you can setup a development environment on your own server or your laptop (or whatever), tinker with the files, and templates, and so on — until it's all done.

And whenever you are done, it's time to move files.

Sounds easy? It sort of is!

Checklist

Here's a small check list of things to keep in mind when you move an installation.

  1. You may need to fix up the configuration file in order to adjust all database related settings. It's located in app/etc/local.xml.

  2. Certain directories will need to be made writable. Writable in this case means that the webserver has to be able to write into it. Since most of the standard PHP setups are with mod_php, this will be the user www, apache or www-run (in most cases). If you (or your provider) runs php-cgi, chances are that this is not necessary.

    You may have to ask an administrator to set this up. If the administrator is not available, you can always chmod 777 these, but for obvious reasons this may be risky in a shared environment.

    The following is a list of directories (and contents) which need to be made writable:

    • app/etc/
    • var/
    • media/

    And in case you want to use MagentoConnect, there are additional directories to make writable. Please see this blog post for more info.

  3. URLs, URLs, URLs. You were working on localhost all this time and now you think you can move it over just like that? Wrong!!! ;-) But all you need to do is edit the following keys in the core_config_data table:

    • web/unsecure/base_url
    • web/secure/base_url

That's all folks!

If you have any additions, please leave a comment!

Defined tags for this entry: , , ,

Magento: Error: Please check for sufficient write file permissions

Thursday, April 30. 2009
Comments

Moving a store from one server to another server, you're bound to have small issues. While 99% of the configuration is stored in app/etc/local, there are other bits and pieces that are more spread out. For example, I noticed that there's no central 'Are all file permissions OK?' screen in Magento Commerce and at times the system is pretty secretive when it comes to error messages.

For example, after moving a store from a linux to a BSD (essentially a different WWW user id), Magento Connect just died with "Error: Please check for sufficient write file permissions".

Of course it did not disclose what exactly it failed in the process. Anyhow — debugging in downloader/Maged/Controller.php (Maged_Controller::isWritable()), here's a list of files and directories that need to be made writable so Magento Connect gets to work:

/path/to/your/magento-install

/path/to/your/magento-install/downloader

/path/to/your/magento-install/downloader/config.ini

/path/to/your/magento-install/downloader/pearlib/config.ini

/path/to/your/magento-install/downloader/pearlib/pear.ini

/path/to/your/magento-install/downloader/pearlib/php

Who knows — maybe the secrecy is for security reasons or whatever. In the end the list above is incredibly helpful, when you realized that the linked entry from the knowledge base is missing half of them and/or does not list the relevant parts for Magento Connect there. :D

Defined tags for this entry: ,

How to setup multiple stores on different domains with Magento

Wednesday, April 22. 2009
Comments

Multiple stores is probably the killer feature of the Magento Commerce store. It enables the needy to manage multiple stores through a single interface. Your very own mall in a box.

It's also a management/deployment nightmaredream come true. A single piece of software powering multiple websites.

This small HowTo requires a working installation of Magento (tested with Magento Commerce v1.3), multiple stores setup already, an understanding of your (web)server, some shell-fu and probably root access.

I won't go into creating virtual hosts, and if you're stuck with CPanel, Plesk or similar, this may work as well but I can't help you very much.

Making it work

Magento is complex and so on, but let's disregard the caveats for now and figure out how to make it run.

This setup is one of the things that took me a good while to research, so I'm sharing this so it jump starts others. I remember I had a wiki or knowledge base entry over at Magento bookmarked, but that one seemed to have vanished.

My file system layout is as follows:

/web/customer/magento/1.3/

/web/customer/magento/1.0/

/web/customer/example.org/htdocs

/web/customer/example.net/htdocs

Now, let's say you have a store setup for example.org and one setup for example.net, then place an index.php with the following contents in each htdocs directory:

<?php
require_once '/web/customer/magento/1.3/app/Mage.php';
Mage::run('STORE-CODE', 'store');

The STORE-CODE is hidden in your Magento Commerce Admin. Go to System > Configuration and then click on the designated Store View.

Last, but not least — add the following symbolic links inside both htdocs directories:

ln -s ../../magento/1.3/app/ ./app
ln -s ../../magento/1.3/downloader ./downloader
ln -s ../../magento/1.3/js/ ./js
ln -s ../../magento/1.3/media/ ./media
ln -s ../../magento/1.3/skin/ ./skin
ln -s ../../magento/1.3/var/ ./var

Of course you may need to adjust the paths around, but aside from that, it's all straight forward.

And that is all!

Update: Updated instructions for symlinking (added downloader).

Defined tags for this entry: , ,