Skip to content

Instantly share code, notes, and snippets.

James Deathe jdeathe

Block or report user

Report or block jdeathe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jdeathe
jdeathe / cloud-config-docker-el7.yml
Last active Sep 24, 2019
Cloud-Init user-data to install Docker on CentOS-7
View cloud-config-docker-el7.yml
#cloud-config
---
timezone: "UTC"
write_files:
- path: "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7"
permissions: "0644"
owner: "root:root"
content: |
-----BEGIN PGP PUBLIC KEY BLOCK-----
@jdeathe
jdeathe / php-curl-status.php
Last active Feb 8, 2019
Basic health status check using PHP curl
View php-curl-status.php
<?php
$responseCode = 500;
$responseCodeOk = 200;
$responseCodeFail = 503;
$url = 'https://www.deathe.org/';
$ch = curl_init();
curl_setopt_array(
@jdeathe
jdeathe / file-listing-by-date.md
Last active Oct 2, 2018
Linux / Simple File List for Review
View file-listing-by-date.md

Generate a File Listing for Review

Fields

  • Last Modified
  • Size (bytes)
  • Relative Path

Command

Replace {{search-path}} with the path to search.

@jdeathe
jdeathe / identify-php-cgi-process-memory-usage.md
Last active Sep 25, 2018
Identify PHP FastCGI Process Memory Usage
View identify-php-cgi-process-memory-usage.md

Identify PHP FastCGI Process Memory Usage

pmap -x $(ps ax \
  | grep php-cgi \
  | grep -v grep \
  | awk '{ print $1 }' \
  | awk -v RS='' '{ gsub("\n", " "); print; }'\
) | grep -E '^(Address|total)'
@jdeathe
jdeathe / mysql-query-logging.md
Last active Jul 20, 2018
How to Enable MySQL Query Logging at Runtime
View mysql-query-logging.md

How to Enable MySQL Query Logging at Runtime

From the mysql client run:

mysql> SET GLOBAL general_log=true;
mysql> SET GLOBAL general_log_file='general.log';

After this queries will be logged to the named file located in the MySQL data directory. e.g. /var/lib/mysql/general.log.

@jdeathe
jdeathe / centos-6-php-ius-audit.md
Created Jun 8, 2018
Identify Unavailable IUS Packages Between PHP 5.6 and 7.1
View centos-6-php-ius-audit.md

Identify Unavailable IUS PHP Packages Between 5.6 and 7.1

For all installed packages prefixed with php56u, check for availability php71u package.

# yum list installed \
| grep -o '^php56u[^ ]*' \
| { \
  mapfile -t packages; \
  for package in "${packages[@]}"; do \
@jdeathe
jdeathe / get-apache-namevhost-alias-to-configs.md
Created May 30, 2018
BASH one liner to output Apache config files for NameVirtualHosts
View get-apache-namevhost-alias-to-configs.md

The output of apachectl -S is really useful but it's not easy to parse in a script. To make it easier to find the configuration file for a given NameVirtualHost host the following BASH one liner returns lines of output that can be easily parsed.

# apachectl -S 2>&1 \
| sed -rn -e '/NameVirtualHost$/,$ { /NameVirtualHost$/d; $ d; p; }' \
| sed -rn -e 's/^.*(port ([0-9]+) namevhost|alias) ([^ ]*)( )?(\((.*):[0-9]+\)|$)/\2 \6\n\3/p' \
| sed -r -e '/^$/d' -e 's/(.*\.conf$)/\n\1/g' \
| awk -vRS='' '$1=$1' \
| sort -n \
| uniq
@jdeathe
jdeathe / centos-wildcard-certbot.md
Last active Aug 14, 2018
Installation and Usage of Certbot on CentOS to Obtain a Let’s Encrypt Wildcard TLS/SSL Certificate.
View centos-wildcard-certbot.md

Requesting a Wildcard Certificate with Certbot on CentOS

To request a Let's Encrypt wildcard certificate there are the following prerequisites:

  • The client must support ACME v2 (i.e Certbot >= 0.22.0)
  • The DNS-01 challenge type must be used.
  • The --server option or configuration directive must be changed to the appropriate v2 endpoint.

Installation

Install certbot-auto

@jdeathe
jdeathe / grow-root.service
Last active Aug 26, 2018
CentOS-7 Systemd Unit File to Grow the Root LVM Disk on AWS EC2 Instances with an ext4 File System.
View grow-root.service
# To install:
# sudo cat grow-root.service > /etc/systemd/system/grow-root.service
# sudo systemctl daemon-reload
# sudo systemctl enable -f grow-root.service
#
# Start (auto disables after first successful expansion):
# sudo systemctl start grow-root.service
#
# Debugging:
# sudo systemctl status grow-root.service
@jdeathe
jdeathe / jadu-cms-readable-urls-for-custom-scripts.md
Last active Sep 19, 2017
Jadu Continuum CMS - Readable URLs for Custom Scripts
View jadu-cms-readable-urls-for-custom-scripts.md

Jadu Continuum CMS - Readable URLs for Custom Scripts

The recommended location for custom scripts written for the Jadu CMS platform is within /public_html/site/custom_scripts/ but this can lead to long and unfriendly URLs. Here we show how to use the Readable URLs feature to create a cleaner URL structure for a simple custom script.

Installation

  1. Create a new directory <install-path>/public_html/site/custom_scripts/php_version and populate it with the following files:
  • htaccess_readable
You can’t perform that action at this time.