Magento Community Edition is an Open Source eCommerce solution that gives developers complete code visibility and small businesses an affordable way to create unique and engaging sites. It's the leading eCommerce platform, running over 25% of all eCommerce websites. In addition, Magento is supported by a vibrant developer community that continually advances the platform by contributing code. In this tutorial, we will deploy the Magento Community Edition on CenturyLink AppFog, backed by an AppFog MySQL instance.

Using the Magento Blueprint

CenturyLink Cloud® offers a Blueprint for deploying a fully-configured Magento installation. The Magento Blueprint is ideal for provisioning a production-ready system, complete with virtual servers and cloud database access. You can read more in our Knowledge Base article about deploying the Magento Blueprint.

Deploying Magento on AppFog is better for smaller installations; it's ideal for environments where a full virtual server isn't needed. AppFog deployments are also well-suited for testing the latest, bleeding-edge Magento versions, customized Magento installations, and Magento software development.

Tools Used

AppFog is our Platform-as-a-Service (PaaS) offering based on Cloud Foundry. It allows you to easily host cloud-native applications without worrying about provisioning and maintaining servers and separate services. AppFog applications deploy quickly and scale automatically while providing access to the full range of CenturyLink Cloud products.

Magento Community Edition is written in PHP, but you won't need to actually know PHP to complete the tutorial. However, you might want to be familiar with Composer for PHP, which is used to handle project dependencies.

Before We Start

You’ll need access to AppFog. If you don’t have a CenturyLink Cloud account, migrate to the CenturyLink Platform with free onboarding assistance and receive a matching spend credit. The credit is based on your initial commitment period of platform use.

You will also need to create a Magento account. To do this, visit the Magento home page, create a New Customer account, and complete the registration process.

Configuring Magento Community Edition for Deployment

To deploy an application to AppFog, to start by configuring the Magento Community Edition package on your local system. Follow these steps to download and unpack the software.

  1. Visit the Magento site and download the software.
  2. Find the "Full Release (ZIP with no sample data)" section.
  3. Select the ".zip" version from the "Select your format" drop-down menu. Full Release
  4. Click Download.
  5. If you are working on a remote system, transfer the downloaded file to the remote system.
  6. In a new directory, unzip the downloaded file using these commands.
        $ mkdir magento
        $ cd magento
        $ unzip ~/Downloads/
    Note: Replace the filename in the last line with the path to the file you downloaded in Step 4.

Creating the Project Manifest

A manifest file sends important configuration information to AppFog, including resource allocation and environment variables.

  1. In your project directory, create a manifest.yaml file with a text editor. Edit the file to look like this:
         - name: <my-project-name>
           memory: 512M
           instances: 1
             CF_STAGING_TIMEOUT: 15
             CF_STARTUP_TIMEOUT: 15
  2. Set the name attribute to your project name. The name can’t contain any spaces. AppFog uses a global project namespace. The name has to be unique.

Creating a Buildpack Configuration

Buildpacks provide framework and runtime support for AppFog applications. Since the Magento Community Edition is a PHP application, your project will use the PHP buildpack. This includes PHP, Apache HTTPD, and other essential support programs. We need to configure the PHP buildpack.

  1. In your project directory, create a .bp-configdirectory by running mkdir .bp-config.
  2. Using a text editor, create .bp-config/options.json and edit the file to look like this:
          "COMPOSER_VENDOR_DIR": "vendor",
          "WEB_SERVER": "httpd",
          "WEBDIR": "/",
          "PHP_EXTENSIONS": [ "bc-math", "curl", "gd", "intl", "mbstring", "mcrypt",
                              "mhash", "openssl", "pdo", "pdo_mysql", "simplexml", "soap",
                              "xml", "xsl", "zip" ]

Configure the Buildpack Web Server

To run smoothly, the Magento Community Edition needs specific Apache HTTPD modules to be enabled.

  1. In your project directory, run mkdir -p .bp-config/httpd/extra.
  2. Using a text editor, create .bp-config/httpd/extra/httpd-modules.conf and edit the file to look like this:

        LoadModule authz_core_module modules/
        LoadModule authz_host_module modules/
        LoadModule log_config_module modules/
        LoadModule env_module modules/
        LoadModule setenvif_module modules/
        LoadModule dir_module modules/
        LoadModule mime_module modules/
        LoadModule reqtimeout_module modules/
        LoadModule unixd_module modules/
        LoadModule mpm_event_module modules/
        LoadModule proxy_module modules/
        LoadModule proxy_fcgi_module modules/
        LoadModule remoteip_module modules/
        LoadModule rewrite_module modules/
        # Needed for Magento
        LoadModule access_compat_module modules/
        LoadModule alias_module modules/

Configure Magento Download Authentication

The PHP buildpack uses Composer to manage project dependencies. Magento requires user authentication to download and install packages using Composer. Here are the instructions.

  1. Go to the Magento Connect account page and log in using your Magento account.
  2. In the "My Account" section, click Connect.
  3. In the "Developers" menu, click Secure Keys.
  4. If no keys are listed, enter a name in the "Name" box and click Generate.
  5. Record the "Public Key" and "Private Key". You will need this information later.
  6. Using a text editor, create a auth.json file in your project directory and edit the file to look like this:
          "http-basic": {
            "": {
              "username": "<your-public-key>",
              "password": "<your-private-key>"
  7. Replace <your-public-key> and <your-private-key> with the public and private keys you recorded in Step 5.

Configure Cloud Foundry Tools

Since the PHP buildpack handles all of the project dependencies, we don't want to waste time and resources uploading extra files.

  1. Using a text editor, create a .cfignore file in your project directory and edit the file to look like this:

Enable Magento Background Tasks

  1. Using a text editor, open pub/.htaccess.
  2. Find the line containing Deny access to cron.php
  3. Edit the following section to comment out these lines:
        ## Deny access to cron.php
        #    <Files cron.php>
        #        order allow,deny
        #        deny from all
        #    </Files>

Altering the Magento Installation

By default Magento is configured to overwrite existing files during installation. We need to update the Composer configuration files to disable that behavior.

  1. Using a text editor, open composer.json.
  2. Find the line near the end of the file that says "extra": {.
  3. Delete the last section of the file so it looks like this:
         "minimum-stability": "alpha",
         "prefer-stable": true
  4. Run the following command to remove the composer.lock file.
    $ rm composer.lock

Deploying Your Application to AppFog

At this point, configure AppFog in your CenturyLink Cloud account and prepare your app for deployment. To get a good understanding of AppFog, we recommend reading the Getting Started Guide. The following steps will get you up and running quickly.

Enable AppFog

First, enable AppFog in the CenturyLink Cloud Control Portal.

  1. Go to the Control Portal and log in.
  2. Select AppFog from the drop-down menu. Magento Blueprint
  3. Select a region to host your application. Control Portal

Log in to AppFog using the Cloud Foundry Tools

Once AppFog is set up in your CenturyLink Cloud account, you need to log in to AppFog using the Cloud Foundry CLI. The Control Panel gives you an exact command from the Overview tab.

  1. Find the cf login command on your AppFog control panel. It will look similar to this:
        cf login -a -o C007 -u your.username
    Login Panel
  2. Run the command in your project directory.
  3. Enter your CenturyLink Cloud password when prompted. Passowrd
  4. Select the Dev application space. Dev App Space

    Note: To learn more about logging into AppFog using the Cloud Foundry command-line tools, read this Knowledge Base article.

Deploy Your Application

After the initial configuration and login, deployment is just one command.

  1. Run the following command in your project directory.
        $ cf push
  2. Record the URL of your application for later use.

    A successful deployment produces a lot of output and looks similar to this when it finishes: Success

Creating a CenturyLink MySQL service

Your Magento Community Edition system is almost ready. Before going through the Setup Wizard, we need to provision a CenturyLink MySQL database.

  1. Create a MySQL service and bind it to your AppFog application by running the following commands in your project directory.

        $ cf create-service ctl_mysql micro <your-database-name>
        $ cf bind-service <your-app-name> <your-database-name>
        $ cf restage <your-app-name>

    Replace <your-database-name> and <your-app-name> with the name of your AppFog application and a database name.

  2. To find your MySQL configuration and authentication information run the cf env command:

        $ cf env <your-project-name>
         "VCAP_SERVICES": {
          "ctl_mysql": [
            "credentials": {
             "certificate": "-----BEGIN CERTIFICATE-----{...}-----END CERTIFICATE-----",
             "dbname": "{database name}",
             "hostname": "{hostname}",
             "password": "{password}",
             "port": {port},
             "username": "{username}"
            "label": "ctl_mysql",
            "name": "<your-database-name>",
            "plan": "micro",
            "tags": []
  3. Record the database name, hostname, password, port, and username for use with the Magento Setup Wizard.

For more information on using CenturyLink MySQL with AppFog applications, read this Knowledge Base article.

Run the Magento Setup Wizard

Your Magento Community Edition application is now ready for the Magento Web Setup Wizard. Go through the instructions outlined in the Magento documentation. When it comes time to enter your database host name, use the hostname and port you recorded in the previous section, separated by a colon. For example, if your database hostname is and your port number is 5916, you would enter as your database host name in the Setup Wizard.

Set up cronjob to run Magento cron.php

In order for Magento Community Edition to run and process orders correctly, it's important to make sure that periodic tasks are executed. In a hosted server environment, this is done with a program called cron. However, with cloud hosting an external service is needed.

There are a few cloud-based webcron services available. Check out SetCronJob and EasyCron for a few examples. You will want to set up the cron job to execute a web request to http://<your-app-url>/pub/cron.php. Make sure to replace <your-app-url> with the base URL of your AppFog application.

Other Resource

You might be interested in checking out this article as well: Deploying WordPress on AppFog


Magento is the eCommerce shopping cart software and platform written in PHP that's trusted by the world's leading brands. Deploying that technology in AppFog is now easier than ever.

Sign-up for our Developer-focused newsletter, CODE. Designed hands-on by developers, for developers. Keep up to date on topics of interest: tutorials, tips and tricks, and community building events.

We’re a different kind of cloud provider – let us show you why.