Presentation on theme: "DRUPAL ON VIRTUALISED INFRASTRUCTURE - AWS - GENERIC VPS - ETC. CHARLES CORRIGAN – 19 TH MARCH 2013."— Presentation transcript:
DRUPAL ON VIRTUALISED INFRASTRUCTURE - AWS - GENERIC VPS - ETC. CHARLES CORRIGAN – 19 TH MARCH 2013
IT STARTED WITH A KICKSTARTER CAMPAIGN http://www.kickstarter.com/projects/224590870/the-guide-to-glorantha http://www.kickstarter.com/projects/224590870/the-guide-to-glorantha Wild success, raised much more than expected! Attracted a lot of traffic to the website Shared hosting provider told us we were using too much CPU After warnings, provider cut our service for 24 hours We needed an alternative. Quickly!
RESCUED BY DRUPAL PLANET Just before that happened, I flagged a blog posting by Randall Knutson http://www.leveltendesign.com/blog/randall-knutson/create-high-performance- drupal-server-just-30-month I ended up not following his recipe exactly
WHAT I WILL COVER Choosing a provider Creating a server in AWS Choosing an operating system Installing and configuring the software stack on Ubuntu
DEFINITIONS Virtualisation Partitioning a ‘large’ physical resource in such a way that a user of a virtual partition appears to have full access to and control of a smaller physical resource. Computer – CPU + Memory Storage and much more, outside the scope of this discussion VPS – Virtual Private Server AWS – Amazon Web Services
PROVIDERS Acquia – https://www.acquia.com/products-services/acquia-cloud – Drupal specialists, value add layered on AWS https://www.acquia.com/products-services/acquia-cloud AWS (Amazon Web Services) – http://aws.amazon.com/ – datacenter in Singapore http://aws.amazon.com/ Softlayer – http://www.softlayer.com/cloudlayer/ – datacenter in Singapore http://www.softlayer.com/cloudlayer/ Azure (Microsoft) – http://www.windowsazure.com/ – Windows, datacenter in Singapore http://www.windowsazure.com/ Rackspace – http://www.rackspace.com/cloud/overview/ http://www.rackspace.com/cloud/overview/ many more Decision criteria include PricingFunctionalityPerformance: CPU & Memory ServiceFlexibility & ScalingPerformance: Storage IOPS LocationReputation & ReliabilityPerformance: Network and Internet
WHAT WE DECIDED We ended up choosing a cheap provider, local to my friend’s business and home A2 Hosting – http://www.a2hosting.com/http://www.a2hosting.com/
AWS – AMAZON WEB SERVICES Amazon provide a number of different virtualisation services via the web The base virtual computing service is EC2 or Elastic Cloud Compute Can create configurations from basic up to multiple load-balanced servers A basic EC2 instance can service a moderately loaded Drupal site costs around US$30 / SG$40 per month the first month should be free Getting started documentation http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html
CREATING A VPS WITH AWS Sign up to AWS at http://aws.amazon.com/ – have your credit card ready!http://aws.amazon.com/ Go to the EC2 console at https://console.aws.amazon.com/ec2/v2/homehttps://console.aws.amazon.com/ec2/v2/home Choose a region by price (USA regions can be slightly cheaper); or by location (close to users for performance or legal reasons) Click on the “Launch Instance” button Name the virtual server (important if you will have multiple servers) Create (or re-use) an SSH key pair to allow you to login to the server Choose the base operating system image (the Launch Configuration) Click Continue Optionally click Edit Details for advanced settings Click Launch
YOUR NEW VIRTUAL SERVER A short while later (half a minute), your new server should be up and running. More to do, more to do… Set up and assign a fire-wall policy, through Security Groups If you want a publicly accessible server, create and assign an Elastic IPs address If you want additional ‘disks’, create and assign volume(s) in Elastic Block Store Connect to the new server, using SSH and the Key Pair generated earlier Install the additional packages and configure services
CHOOSING AN OPERATING SYSTEM Ubuntu Desktop and Server variants LTS (long term support) or semi-annual upgrades Based on Debian Free SUSE Enterprise Linux Server Paid support Windows Paid Licensing and Support Not the usual webstack for Drupal Red Hat Enterprise Linux (RHEL) Paid support Reputation for high technical excellence CENTOS Based on RHEL from Red Hat Spotty record for timely releases Free A possibility for AWS is an AMI (Amazon Machine Image), which is a pre-built operating system and applications stack, such as BitNami Drupal
SETTING UP AN UBUNTU SERVER – BASICS CommandExplanation apt-get update Updates the list of available software packages apt-get upgrade Upgrades all installed packages to latest versions, particularly security releases The above two commands should be run in sequence as the first thing when you first login to the server. Thereafter, run again about once a week to ensure that the needed security updates are applied in a timely fashion. I haven’t yet found a way to automate this. Some package upgrades will require a server reboot.
SETTING UP AN UBUNTU SERVER – BASICS 2 CommandExplanation apt-get install Install a software package. If a package depends on other packages, then the system will prompt to confirm whether to download and install both the requested package and also the additional dependencies You may be asked additional questions during the installation of some packages. For example, the new root password for MySQL apt-get install Install a list of packages
UBUNTU 12.04 “LAMP” STACK PACKAGES PackageDescriptionVersion apache2Apache webserver2.2.22 mysql-clientMySQL database client software5.5.29 mysql-serverMySQL database server software5.5.29 libapache2-mod-php5PHP in Apache5.3.10 php5-cliPHP command line5.3.10 php5-mysqlMySQL library for PHP memcachedMemory cache server – PERFORMANCE 64Mb should be more than enough for a small site 1.4.13 drushDrupal command line utilities4.5
ADVICE: SETTING UP AN UBUNTU SERVER Try to locate Ubuntu packages rather than installing software from other sources Installing from other sources may compromise your ability to cleanly upgrade the operating system in future, with potential security implications Exceptions: Drupal and other web-facing packages written in scripting languages Try to avoid directly updating the settings files created by Ubuntu For major packages, Ubuntu provides simple ways to safely override settings Directly updating settings files may compromise your ability to cleanly upgrade the operating system in future, possibly leading to your important changed settings being lost during an upgrade
UBUNTU POSSIBLE PACKAGES - 1 PackageDescription php5-curlFiles via internet library php5-gdGraphics library php5-geoipIP geography library php5-imagickGraphics library php5-mcryptEncryption library php5-memcacheMemory cache library – PERFORMANCE php5-memcachedMemory cache library – PERFORMANCE php-apcKeeps 'compiled' php in memory – PERFORMANCE
UBUNTU POSSIBLE PACKAGES - 2 PackageDescription awstatsWebserver statistics - requires manual configuration curlhttp utilities diffComparison utilities geoip-databaseDatabase linking ip addresses to countries gitVersion control software lessTool for looking through logs patchSoftware management utility, part of a VCS
UBUNTU POSSIBLE PACKAGES - 3 PackageDescription phpmyadminWeb front end to manage MySQL databases php-pearTool to install the PEAR and PECL libraries for PHP unzipFile compression management vimProgrammers’ editor webalizerWebserver statistics – needs manual setup wgetTools to get files via the internet NOTES: The listed packages are hints, some of which you will not need. You may need many more packages depending on your requirements!
PHP Create files with settings overrides in/etc/php5/conf.d Typical PHP overrides – exact values depend on your requirements upload_max_filesize = 4M memory_limit = 256M include_path = ".:/usr/share/php“ APC settings apc.shm_size = 64M; add 48 - 64M per additional Drupal site apc.apc.stat = 0 Memcache settings memcache.hash_strategy="consistent"
APACHE Enable modules by adding symbolic links in/etc/apache2/mods-enabled to the required file(s) from/etc/apache2/mods-available There may be 2 settings files for 1 module: eg. alias.load and alias.conf Remove unwanted modules by removing the link(s) in /etc/apache2/mods-enabled Create your site definitions in/etc/apache2/sites-available and enable the site by creating a symbolic link in/etc/apache2/sites-enabled Particularly useful when creating several virtual hosts Create files with settings overrides in/etc/apache2/conf.d
NEARLY THERE Install uploadprogress; type the following commands pecl install uploadprogress echo 'extension=uploadprogress.so' > /etc/php5/conf.d/uploadprogress.ini I haven’t found an Ubuntu package for this The 2 nd line is an example of how to cleanly set up a PHP override Reboot the server Start setting up Drupal in the default location of /var/www After Drupal is set up and confirmed working…
ENABLE MEMCACHE Drupal 6: add the following lines tosites/default/settings.php $conf['cache_inc'] = 'sites/all/modules/memcache/memcache.inc'; $conf['memcache_key_prefix'] = 'something_unique'; Drupal 7: add the following lines to sites/default/settings.php $conf['cache_backends'] = 'sites/all/modules/memcache/memcache.inc'; $conf['cache_default_class'] = 'MemCacheDrupal'; $conf['memcache_key_prefix'] = 'something_unique'; Only important if you are hosting multiple sites
WEB ADMINISTRATION Webmin – http://webmin.com/http://webmin.com/ Not packaged Moderately complex to install More focused on server administration ISPConfig – http://www.ispconfig.org/http://www.ispconfig.org/ Not packaged Difficult to work out and install all dependencies Very complex to install, required a lot of research and hand editing to complete Easier to use for common tasks, such as to create virtualised email and websites within the virtual server
BACK-UPS I have yet to do this correctly! I am currently only backing up database and keeping the backups on the virtual server! Drupal Planet and Randall Knutson to the rescue again http://www.leveltendesign.com/blog/randall-knutson/yet-another-simple-amazon-s3- backup-script-drupal