Press "Enter" to skip to content

Category: Life: Work and Techy

Running Jenkins CI for PHP on Amazon EC2 [6/7]

Continued from Installing and Configuring Jenkins CI

Make a backup of the Amazon EC2 configuration

  1. Log into your Amazon Ec2 account
  2. Under the “My instances” select your Jenkins install
  3. Under “Instance Actions” to “Create Image (EBS AMI)” and give it an appropriate name and description

It is advisable to shutdown your EC2 image when you are not using it to avoid billing (not so important with the free Micro instance, but a good practice to get into)

Continued in Relaunching the Amazon EC2 image

Running Jenkins CI for PHP on Amazon EC2 [5/7]

Continued from Connecting to Amazon EC2 using PuTTY

Installing and Configuring Jenkins CI

  1. Connect to your Amazon EC2 image as per Connecting to Amazon EC2 using PuTTY
  2. In the SSH window, run: sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
  3. In the SSH window, run: sudo rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
  4. In the SSH window, run: sudo yum install jenkins
  5. In the SSH window, run: sudo service jenkins start
  6. Whilst we are waiting for Jenkins to start up, we can install PHP and associated modules
  7. In the SSH window, run: sudo yum install php git
  8. In the SSH window, run: wget http://pear.php.net/go-pear.phar;sudo php go-pear.phar
  9. You will be prompted if you want to make any changes to the PEAR installation. Select to change the “Installation base ($prefix)” 1 to /usr
  10. You will be prompted if “Would you like to alter /etc/php.ini”, select “Yes”
  11. In the SSH window, run: sudo pear config-set auto_discover 1
  12. sudo yum install php-devel gcc make ImageMagick ImageMagick-devel php-dom php-pdo dbus-devel libxml2 libxml2-devel ant php-mbstring swig

  13. In the SSH window, run: sudo pecl install xdebug channel://pecl.php.net/dbus-0.1.1
  14. In the SSH window, run: sudo pear install pear/XML_RPC2 pear.phpqatools.org/phpqatools PHPDocumentor pear.phpunit.de/PHPUnit channel://pear.php.net/Text_Highlighter-0.7.1 channel://pear.phpundercontrol.org/phpUnderControl-0.6.1beta1 channel://pear.php.net/HTTP_Request2-2.0.0RC2 channel://pear.php.net/Net_URL2-0.3.1 pear.pdepend.org/PHP_Depend phpunit/PHP_CodeBrowser channel://pear.docblox-project.org/docblox-0.15.1
  15. In the SSH window, run: sudo su
  16. In the SSH window, run: echo 'zend_extension="/usr/lib64/php/modules/xdebug.so"' >> /etc/php.ini
  17. In the SSH window, run: echo 'extension=dbus.so' >> /etc/php.ini
  18. In the SSH window, run: echo 'date.timezone="Etc/UTC"' >> /etc/php.ini
  19. In your web browser, go to http://ec1-23-456-78-901.xx-yyyy-1.compute.amazonaws.com:8080 (where http://ec1-23-456-78-901.xx-yyyy-1.compute.amazonaws.com is the hostname of your Amazon EC2 image)
  20. Click “Manage Jenkins” on the left hand side and then select “Configure system” (in Chrome, you may get the “LOADING…” grey screen covering most things for a long time, just try a different browser)
  21. Select “Enable security”
  22. Under “Access Control->Security Realm” select “Jenkins’s own user database” and tick the “Allow users to sign up”
  23. Under “Authorization” select “Matrix based security”
    • Along side “Anonymous” select “Overall->Read”
    • In “User/group to add” add your preferred username and click “Add”
    • Give yourselves full access by checking the entire row
  24. Scroll down and click “Save”
  25. From the home page of Jenkins click “Sign-up now”
  26. Enter the same username as you did before and your preferred password, name and email address. Click “Sign up”
  27. Once you’ve logged back in, select “Manage Jenkins” and “Manage Plugins”
  28. Select “Available” and check the following plugins:
    • Checkstyle
    • Clover PHP
    • DRY,
    • JDepend
    • Plot
    • PMD
    • Violations
    • Analysis Collector Plugin
    • xUnit

    If you are developing using GitHub, also select “Github Plugin”

  29. Scroll down and click “Install”
  30. Wait and then select “Restart Jenkins when no jobs are running”
  31. Wait whilst Jenkins restarts
  32. Go back to “Manage Jenkins->Configure System”
  33. Scroll down to “Ant” and “Add Ant” and call it “Ant” and select “Install automatically”
  34. Under the “E-mail notification” under the “Default user e-mail suffix” and “@” followed by your domain name and your email address under “System admin e-mail address”
  35. Click Save
  36. Continued in Make a backup of the Amazon EC2 configuration

Running Jenkins CI for PHP on Amazon EC2 [4/7]

Continued from Preparing PuTTY for Amazon EC2

Connecting to Amazon EC2 using PuTTY

  1. Load PuTTY
  2. In the Hostname box, enter the Public DNS entry of your Amazon EC2 instance (ec1-23-456-78-901.xx-yyyy-1.compute.amazonaws.com)
  3. Click, in the left hand side of the PuTTY window, Connection->SSH->Auth
  4. In the “Private Key Field” select the file you saved from “Preparing PuTTY for Amazon EC2
  5. Click “Open”
  6. Login as “ec2-user”

Continued in Installing and Configuring Jenkins CI

Running Jenkins CI for PHP on Amazon EC2 [3/7]

Continued from Signing up to Amazon EC2 and starting your first image

Preparing PuTTY
Note: These instructions are based on the Windows version of PuTTY and PuTTYgen

  1. Download an install PuTTY and PuTTYgen from http://www.chiark.greenend.org.uk/~sgtatham/putty/ (if there is an “install all” install for your platform, use that)
  2. Load PuTTYgen
  3. Click Load (“Load an existing private key file”)
  4. Select “Show all files (*.*)” in the “Load” box instead of the “PuTTY Private Key Files (*.ppk)”
  5. Select your Amazon EC2 Key (such as AmazonInstance.pem)
  6. Click Load
  7. You should receive the “Succesfully imported foreign key” message
  8. Click “Save private key” (select Yes to “Are you sure you want to save this key without a passphrase to protect it?”)
  9. Save the file somewhere save

Continued in Connecting to Amazon EC2 using PuTTY

Running Jenkins CI for PHP on Amazon EC2 [2/7]

Continued from Part 1 – Introduction

Signing up to Amazon EC2 and starting your first image

  1. Sign up to Amazon’s AWS service at http://aws.amazon.com
  2. You will be prompted for payment details, but you won’t be charged if you use Amazon’s free Micro EC2 instance
  3. Wait for your account to be created – you will get an email once done, but it’ll take a few hours (it took me 3 hours)
  4. Log back into http://aws.amazon.com and select “Amazon EC2”
  5. Select the closest region to yourself in the left hand side
  6. Select “Launch instance” and, if prompted, select “Launch classic wizard”
  7. Select, from the Quck Start tab, the “Basic 64 Bit Amazon Linux AMI” image. This should be near the top and indicated with a big gold star to indicate “Free tier eligible if used with a micro instance”. Click continue
  8. Set the number of instances to 1 and the Instance type to “Micro”.
  9. Under “Launch instances”, select an EC2 availability zone or just leave it set to “No preference”. Click continue.
  10. Ignore the “Advanced instance options” and just click continue
  11. Ignore the Tags page and just click continue
  12. Select “Create a new Key Pair” and give it a name (such as AmazonInstance) and then “Create and download your key pair” and save the file some where important. Click continue.
  13. On the “Create a new security group”, create a name group called “JenkinsSSH” with a description of “Web and SSH access” and:
    • Create a new inbound rule with “Custom TCP rule”, port range “8080”, Source “0.0.0.0/0”. Click Add rule
    • Create a new inbound rule with “Custom TCP rule”, port range “22”, Source “0.0.0.0/0”. Click Add rule
    • Click “Launch” and wait a couple of minutes
    • Once it has launched, scroll down the bottom half of the “My Instances” panel until you see the “Public DNS” and make a record of that entry (ec1-23-456-78-901.xx-yyyy-1.compute.amazonaws.com)

Continued in Preparing PuTTY for Amazon EC2