Deployment for Small- and Medium-Sized Magento Shops

I always encounter two main problems when it comes to the deployment of small- and medium-sized Magento shops. First, when I take over a shop, there is often no deployment process at all. Second, when people talk about the deployment process for Magento shops, it is always about big projects. I understand that this is more challenging and may sound more attractive to some of you, but I think it is also important to talk about the deployment process of smaller Magento shops. So here we go!

But first of all, if you work for big shops, you may be more interested in the following resources:

Most of the approaches discussed there are just overkill for moderately sized shops running on a single web server. But having a deployment process is equally important to them. Why is that the case? Why don’t we just copy and paste the files somehow on the server?

  1. Version Control System: We all use a version control system, preferably git. You should not expose your .git directory. So you are not able to do something simple like a git pull.
  2. Database Updates: Install/upgrade scripts may run multiple times which can lead to various problems.
  3. Inconsistent extension state: When you simple copy and paste the files, an extension may be in an inconsistent state. Some files of the extension may already have been updated, while others may not. This can lead to various problems, including that database updates of this extension are not executed at all.

Convinced that we need a somehow more sophisticated approach? Alright, so what should we basically be doing when rolling out a new version?

  1. Getting the specific version from the version control system (preferably git).
  2. Preparing the code for use in production, meaning:
    1. [only necessary when not using modman] Copying the local.xml with the live database credentials and settings to app/etc.
    2. [only necessary when not using modman] Removing the .git directory (yes, you should do that).
  3. [only necessary when not using modman] Symlinking the media folder
  4. [only necessary when not using modman] Copying session files
  5. Enabling the maintenance mode
  6. Exchanging the old with the new code
  7. Clearing the cache (including APC)
  8. Running the install/upgrade scripts
  9. Disabling the maintenance mode

Interested in some real sample code? I created a GitHub repository containing two sample bash release scripts. One assumes that you have all the Magento code under version control, the other one assumes that you use modman and only have the .modman folder under version control (my preferred way). In order to use them, you theoretically simply need to change the settings in the first section. But since systems and requirements are quite diverse, you may want to simply use the scripts as a template and optimise them for you. Mind that these scripts come with absolutely no warranty. You should test them thoroughly on a test system before using them in production. Feel free to contribute!

Update 2015-08-16: Daniel Fahlke gave me the hint to have a look at Deployer. Interesting idea, although Bash has the advantage that it does not have any dependencies and can be run „everywhere“.

2 Gedanken zu „Deployment for Small- and Medium-Sized Magento Shops“

  1. Thanks for the valuable hints.
    Using „git pull“ for deployment is well possible. If your Magento dir is in a sub directory (like „www“ or „htdocs“ or whatever), your .git dir won’t be exposed as the web root will also point to that sub directory. I do agree though that some sort of deployment makes sense especially because of the need to run update scripts in maintenance mode.
    I’d also recommend using composer in addition to modman as it makes it easier to handle the modules.

    1. Thanks, Andreas! Means much from you!
      Regarding git: When writing this bullet point I knew someone would say that 🙂 Anyway, I guess people barely do it this way.

      Composer is a good addition. I think Magento 2 will be the entry point for me to finally use Composer 🙂

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert