Starting Docker: Installation

Starting Docker: Installation

Thursday, Dec 1, 2016
Unless you have been living under a metaphorical rock you will have heard about Docker. But although lots of people have heard of Docker, far fewer are using it day-to-day and even less in production. In this short post, I am going to go over what Docker (and containers are) and how you can start to get up and running with Docker. What is Docker? Wikipedia describes Docker as: Docker is an open-source project that automates the deployment of Linux applications inside software containers. Docker provides an additional layer of abstraction and automation of operating-system-level virtualization on Linux. ...

Read more
Redirecting http to https on nginx

Redirecting http to https on nginx

Monday, Jul 11, 2016
If you have been following the growth of encryption on the web (https) and the fact that you can now get free SSL certificates (much like the one on this site) using Lets Encrypt, there is very little reason for not having your site running https, making your data encrypted between the server and the user, making everyone more secure. If you are doing this in Apache, then most open-source projects will suggest the you use the rewrite engine inside apache. Something like this: ...

Read more
Tidy Git Repos Using BFG

Tidy Git Repos Using BFG

Friday, Jul 1, 2016
Version control. A saviour of modern development and with everyone using git to manage their code nowadays (at least for the last 5 years) having an understanding of git is an essential part of being a developer. Recently I have become more and more involved in code review, using GitLab, Bitbucket and GitHub to manage code from different developers for different projects. This is made easier by using a workable workflow (something like GitFlow), however, as I am involved in more and more projects of endless dread when I start with project and it has unnecessary, large or sensitive files that have been committed into its history. ...

Read more
Managing Large Numbers of Drupal Sites with Ansible and Drush

Managing Large Numbers of Drupal Sites with Ansible and Drush

Wednesday, May 6, 2015
Our latest Ansible adventure has been the creation of a task structure which we can use to easily manage multiple Drupal websites on multiple servers. It’s easy enough to use the Ansible command module to run drush commands on a bunch of Drupal sites, using the following code (where sites is just a list of Drupal root locations): name: Run drush cc all on each site listed command: "drush cc all chdir=/var/www/{{ item }}" with_items: - sites This is fine if you are only trying to manage sites on a single server, and you could just run this role repeatedly for different servers and change the variable in the playbook to point to a different list of sites. ...

Read more
Ansible Talk at Drupal Cambs

Ansible Talk at Drupal Cambs

Friday, May 1, 2015
This Monday I had the privilege of giving my first talk at the Drupal Cambrdige meetup (@drupalcambs). It was on the subject of using Ansible to provision servers and manage Drupal installations and the slides are embedded below. I had a lot of fun giving the presentation and hopefully it will be the first of many. I just hope the audience had as much of a good time! Just a few accompanying notes for the slides (I didn’t want to overdo it with onscreen text for the presentation, so a lot of it is mainly headlines): ...

Read more
Ansible for Server Monitoring

Ansible for Server Monitoring

Friday, Apr 10, 2015
More Ansible goodness this week. We’ve been working on a basic playbook to set up the innovatively-named Monit monitoring tool to keep an eye on our webservers and give them a kick up the backside if they’re misbehaving. It’s based on a very useful Ansible Galaxy role, pgolm’s Monit, which installs and configures the tool. However, the role’s documentation doesn’t necessarily make it obvious how to get the best from Monit, so here’s an example playbook for monitoring PHP, MySQL and Nginx to get things started: ...

Read more
Embracing Ansible

Embracing Ansible

Tuesday, Mar 24, 2015
Three months ago, we were introduced to the wonders of Ansible at Drupal Camp Brighton. Since then, whenever we’ve had the chance we’ve been working on various Ansible playbooks to automate many of our development and maintenance processes. For a small team like us, Ansible is invaluable. It is reducing the time we need to spend administering our servers and sites exponentially, freeing up extra time for development. Development and testing happen more quickly as well, and we can be more confident about deployment to live running smoothly because of better consistency between our environments. ...

Read more
Routing domains on nginx

Routing domains on nginx

Tuesday, Feb 3, 2015
Alongside developing lots of different websites in Drupal, we also maintain and administer a number of different servers. In this role we occasionally end up managing a number of different domain names. It struck us as interesting that many people don’t really understand the difference between using the domain with or without www, for example www.willhallonline.co.uk and willhallonline.co.uk. They are technically two different subdomains of willhallonline.co.uk, however, it has to be stressed that they are different. You can even extend these to be routed to different locations (servers) or websites. ...

Read more
Max Packet Size PHP Error

Max Packet Size PHP Error

Monday, Jan 19, 2015
We ran into this error PHP Warning: Error while sending QUERY packet. PID=25016 the other day when trying to run an update query on a database with approximately 3.8 million records in it. New data had become available for 2.1 million of these records. These were submitted using a PHP program which fetched and parsed enormous CSV files before using a PDO statement to insert or update the records into MySQL. Upon running the program, the PHP warning would appear. ...

Read more
Quota alerts for email users

Quota alerts for email users

Thursday, Nov 8, 2012
Recently I have been doing quite a few more system administrator tasks around different office. I wrote this bash script (I realise it is probably not perfect to bash officianados, however, it does solve that problem). I have attached the completed file below if you want to download it. Bash Code #!/bin/bash # get all users whose uid is greater than 1000 and less than 60000 for user in `awk -F':' '{if ($3 > 1000 && $3 < 60000) print $1}' /etc/passwd` do # create array as output from quota command array=( $(quota -v $user)) # retrieve amount of space user is using block=${array[17]} #retrieve quota that user is allowed quota=${array[18]} # result = quota - amount used result=$(($quota-$block)) # if result is less than 20000 then do something. The extra part is in as users with unlimited quota are given a quot with 0 therefore will have a negative number. if [ $result -lt 20000 ] && [ $result -gt 0 ] then # email the user and administrator to make them aware echo "Sending email regard $user" (echo "From: admin@server.com" echo "To: $user@server.com" echo "Subject: Your email box is nearly full" echo "Hello, This is your email server speaking. You are running low on email space on the server. Please can you remove any unwanted emails including emails in your Sent and Deleted box. Thank you, Your Server" )| sendmail -t (echo "From: admin@server.com" echo "To: admin@server.com" echo "Subject: $user is running low on space" echo "This is Captain Kirk. $user is running low on space. Do something captain." )| sendmail -t # finish off the if statement and script fi Done. :-) ...

Read more