3
votes

I recently tried to run stack based amazon cloud formation template for WordPress. Unfortunately yum installs old PHP and I got this communicate:

Your server is running PHP version 5.3.29 but WordPress 5.2.1 requires at least 5.6.20.

I change the stack and specify version:

     "install_wordpress" : {
        "packages" : {
          "yum" : {
            "php"          : ["5.6.20"],
            "php-mysql"    : [],
            "mysql"        : [],
            "mysql-server" : [],
            "mysql-devel"  : [],
            "mysql-libs"   : [],
            "httpd"        : []
          }
        },

But still I got same error. How to properly specify version for yum in cloud formation template?

As base template I used default template provided by AWS: https://s3-us-west-2.amazonaws.com/cloudformation-templates-us-west-2/WordPress_Single_Instance.template

1
What OS are you running? - shrewmouse
@shrewmouse Amazon Linux AMI as defined in default WordPress template. I edited question and added link to template. - Mr Jedi

1 Answers

4
votes

You're using ami-0080e4c5bc078760e which is for Amazon Linux 2018.03. According to the package list PHP 5.3 is the latest version available there. You can switch AMI to Ubuntu 16.04 which includes PHP 7.0 or Ubuntu 18.04 with PHP 7.2. You can also manually install a newer version of PHP from source.

Another option is enabling amazon-linux-extras. You need to enable the PHP 7.2 topic before calling cfn-init which will install the packages listed in AWS::CloudFormation::Init. You can also use two config sets. See this example.

Basically:

  "Metadata": {
    "AWS::CloudFormation::Init": {
      "configSets": {
        "default": ["extras", "config"]
      },
      "extras": {
        "commands": {
          "0_enable_php": {
            "command": "amazon-linux-extras enable php7.2",
            "test": "[ ! grep -Fxq '[amzn2extra-php7.2]' /etc/yum.repos.d/amzn2-extras.repo ]"
         }
      }
      "config": {
        "packages": {
          "yum": {
            "php"          : [],
            "php-mysql"    : [],
            "mysql"        : [],
            "mysql-server" : [],
            "mysql-devel"  : [],
            "mysql-libs"   : [],
            "httpd"        : []
          }
        }
      }
    }
  }