290 likes | 495 Views
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 Wild success, raised much more than expected!
E N D
Drupal on Virtualised Infrastructure- AWS- Generic VPS- etc. Charles CorrigaN – 19th March 2013
It started with a KICKSTARTER campaign • 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 • AWS (Amazon Web Services) – http://aws.amazon.com/– datacenter in Singapore • Softlayer– http://www.softlayer.com/cloudlayer/ – datacenter in Singapore • Azure (Microsoft) – http://www.windowsazure.com/ – Windows, datacenter in Singapore • Rackspace – http://www.rackspace.com/cloud/overview/ • many more
What we decided • We ended up choosing a cheap provider, local to my friend’s business and home • A2 Hosting – 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! • Go to the EC2 console at https://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
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
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-enabledto 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-availableand 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 2nd 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 to sites/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/ • Not packaged • Moderately complex to install • More focused on server administration • ISPConfig – 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
apt-get install apache2 mysql-client mysql-server libapache2-mod-php5 php5-cli php5-mysql memcacheddrush php5-curl php5-gd php5-geoip php5-imagick php5-mcrypt php5-memcache php5-memcached php-apcawstats curl diff geoip-database git-core less patch make phpmyadminphp-pear unzip vim webalizerwget