Archive for DevOps

Install NTP on CentOS

1. Install NTP and its documentation. yum install ntp ntp-doc 2. Configure NTP servers to query from. Head to and select the country based on the geographical location of the server. For example, the following servers would be used for a server located in the U.S.: server server server server [...]

Using s3cmd to synchronize local files against an S3 bucket

I use the following command to synchronize a local directory in a web project containing static resources with an S3 bucket. s3cmd \ –ssl \ –skip-existing \ –recursive \ –delete-removed \ –no-preserve \ –guess-mime-type \ –add-header=Expires:2037-12-31T00:00:00Z \ –add-header=Cache-Control:max-age=155520000,public \ –encoding=UTF-8 \ sync ./src/main/webapp/static/ s3://bucketname HTTP response headers are defined per-file rather than per-bucket, and therefore [...]

Setting up Amazon S3 to host static media assets

I have a server with many gigabytes of static images that are starting to consume all of its available disk space. Unfortunately, the server is underpowered and not regularly backed up, which means that requests are not served as quickly as they could be and a system failure means I could lose all of this [...]

Apache httpd + mod_jk Configuration for a 503 “Down for Maintenance” Page

This is a configuration I used to create a “Down for Maintenance” page with a 503 HTTP response code in httpd while I redeploy a Tomcat war file. 1. JkUnMount a static resource Since I have a dedicated server, my mod_jk configuration directs all traffic to Tomcat. In order to have Apache serve a static [...]

Deny requests by IP address on an Apache server

It’s very unlikely that someone will legitimately access your web server by IP address in his or her web browser, and it’s almost guaranteed to be a bot of some sort. To prevent access to your server by IP address, it’s necessary to examine the ‘host’ header in the HTTP request (HTTP_HOST in Apache) and [...]

A simple cron job to perform a recurring MySQL database backup

I’ve written a simple script that performs a MySQL database dump and can be added as a cron job to run at regular intervals. This script will dump the entire database to a file and gzip it, while also creating a log of its activities. Before starting, identify which user the script should run as. I [...]

Regex to identify an IE 6 user agent without blocking MSIE 8 or 9 users

I recently had a need to block all IE 6 users from a web site. After doing some log analysis, it looked like nearly every IE 6 user agent was some sort of bot or undesirable crawler. The browsing patterns made it very obvious that the requests were not coming from a human, and sometimes [...]