DZone
DevOps Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > DevOps Zone > Running Drupal on Amazon EC2 LAMP Config with Serverless Puppet

Running Drupal on Amazon EC2 LAMP Config with Serverless Puppet

Matthew Turland user avatar by
Matthew Turland
·
Feb. 14, 12 · DevOps Zone · Interview
Like (0)
Save
Tweet
8.41K Views

Join the DZone community and get the full member experience.

Join For Free

I’m currently working on a project that involves running Drupal on Amazon EC2. To save time in setting up future new VM instances, I decided to take the opportunity to learn puppet. For the time being, I’m using a single VM to run the full LAMP stack and running puppet without a server by copying my puppet manifest to the VM and using puppet’s apply command to apply it locally. However, this manifest can easily be adapted for a multi-VM environment. After some tinkering, I came up with the code below.

class web {
    package { 'httpd':
        ensure => 'present',
    }
 
    package { 'php':
        ensure => 'present',
    }
 
    # Update this to use your respective time zone value
    exec { 'php_config':
        command => '/bin/sed -i "s/^;date.timezone =/date.timezone = \'America\/Chicago\'/g" /etc/php.ini',
        require => Package['php'],
    }
 
    service { 'httpd':
        ensure => 'running',
        enable => true,
        hasrestart => true,
        hasstatus => true,
        subscribe => Package['httpd', 'php'],
    }
 
    # Drupal requirements start here
 
    package { 'php-pdo':
        ensure => 'present',
        require => Package['php'],
    }
 
    package { 'php-mysql':
        ensure => 'present',
        require => Package['php'],
    }
 
    package { 'php-xml':
        ensure => 'present',
        require => Package['php'],
    }
 
    package { 'php-gd':
        ensure => 'present',
        require => Package['php'],
    }
 
    package { 'php-mbstring':
        ensure => 'present',
        require => Package['php'],
    }
 
    # Drupal requirements end here
}
 
class mysql {
    package { 'mysql-server':
        ensure => 'present',
    }
 
    service { 'mysqld':
        ensure => 'running',
        enable => true,
        hasrestart => true,
        hasstatus => true,
        subscribe => Package['mysql-server'],
    }
 
    # Equivalent to /usr/bin/mysql_secure_installation without providing or setting a password
    exec { 'mysql_secure_installation':
        command => '/usr/bin/mysql -uroot -e "DELETE FROM mysql.user WHERE User=\'\'; DELETE FROM mysql.user WHERE User=\'root\' AND Host NOT IN (\'localhost\', \'127.0.0.1\', \'::1\'); DROP DATABASE IF EXISTS test; FLUSH PRIVILEGES;" mysql',
        require => Service['mysqld'],
    }
}
 
class {'web': }
class {'mysql': }

With this code saved to a file called manifest.pp (.pp being the file extension for puppet manifests), I can spin up a VM and do the following to set it up:

scp -i key.pem manifest.pp ec2-user@host:~/
ssh -i key.pem ec2-user@host
sudo yum upgrade -y
sudo yum install -y puppet
sudo puppet apply manifest.pp
rm -f manifest.pp
exit

At this point, I have a basic Apache/MySQL/PHP configuration capable of receiving a Drupal 7 installation.

Source:  http://matthewturland.com/2012/02/13/setting-up-ec2-for-drupal-with-puppet/

AWS Drupal

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Getting Started Building on the NEAR Network with Infura
  • Troubleshooting HTTP 502 Bad Gateway in AWS EBS
  • JVM C1, C2 Compiler Thread: High CPU Consumption?
  • Easily Format Markdown Files in VS Code

Comments

DevOps Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo