Skip to content

Instantly share code, notes, and snippets.

View jdeathe's full-sized avatar
💭
Taking a break from development projects to focus other things

James Deathe jdeathe

💭
Taking a break from development projects to focus other things
View GitHub Profile
@jdeathe
jdeathe / howto-grep-tail-output.md
Last active April 20, 2024 08:43
How to Grep the Output of tail

How to grep the output of tail

When following a log file with the tail command you are typically looking for a specific pattern. If the log output is verbous it can be difficult to catch the lines your interested in. For example a PHP log file might contain many PHP Notice: entries but your only interested in lines containing PHP Fatal error:. To grep the output of tail simply tell the grep command to red from stdin and pipe the output from tail to grep as follows.

tail -f {path/to/log/file} | grep 'PHP Fatal error:' -
@jdeathe
jdeathe / apache_maintenance_page.md
Last active March 5, 2024 09:47
Simple HTML Maintenance Page for Apache using rewrite_module

Apache - Maintenance Page

  • Activate/Deactivate with a file.
  • Bypass with a custom request header.

With the following Apache Rewrite rule, temporarily redirect all traffic to a maintenance page when a file named maintenance exists at the same level as the DocumentRoot directory. i.e. if your DocumentRoot is /var/www/public_html/ then creating the file /var/www/maintenance would trigger Maintenance mode.

Use something like the ModHeader Chrome browser extension to bypass the maintenance page by setting a X-Maintenance request header with a value of tF0BOCn4z8HgG2Kw (replace this with your own unique passcode string).

Instructions

@jdeathe
jdeathe / kernel-update-with-fast-boot-via-kexec.md
Last active September 17, 2023 20:37
Kernel Update with Fast-Boot via kexec

Kernel Update with Fast Boot via kexec

# <-- NOTE: This represents the command prompt of a root user

Identify the latest installed kernel

# kernel_release_default="$(
 grubby --default-kernel \
@jdeathe
jdeathe / make-local-cert.sh
Last active July 29, 2023 21:30
Generate a Root CA + Intermediate CA for local (internal) use on Mac OSX using cfssl and add the intermediate certificate to your keychain so it can be trusted by your local browser.
#!/usr/bin/env bash
# REF: https://github.com/cloudflare/cfssl
# Change working directory
cd -- "$(
dirname "${0}"
)" || exit 1
readonly CA_ROOT_CERT_KEY="ca-root"
@jdeathe
jdeathe / php-cachetool-usage.md
Last active January 11, 2023 23:46
How to Clear PHP Opcache without Restarting PHP-FPM.

PHP CacheTool - Manage cache in the CLI

Use CacheTool to view stats for and manage PHP's APC or Zend Opcache opcode cache.

Using CacheTool you can clear the PHP opcache without reloading PHP-FPM.

In this example, CacheTool is to be installed alongside a demonstration PHP-FPM Docker container.

Prerequisites

@jdeathe
jdeathe / docker-cron-example.md
Last active December 1, 2022 05:01
How to install/run Cron in a Docker Container

How to install/run Cron in a Docker Container

Example crontab entry for testing

  • Append a timestamp to the log file every minute /var/log/cron.
  • Append "tick" and "tock" in alternate minutes to /var/log/cron.
* * * * * /bin/date --rfc-3339=seconds >> /var/log/cron
*/2 * * * * /bin/echo 'tick' >> /var/log/cron
@jdeathe
jdeathe / centos-6-redis-php-session-handler.md
Last active July 30, 2022 21:24
CentOS-6 - Redis PHP Session Save Handler
@jdeathe
jdeathe / openssl-self-signed-san-certificate.md
Last active June 24, 2022 03:48
How to generate a self-signed SAN SSL/TLS certificate using openssl

How to generate a self-signed SAN SSL/TLS certificate using openssl

Generating a self-signed certificate is a common task and the command to generate one with openssl is well known and well documented. Generating a certificate that includes subjectAltName is not so straght forward however. The following example demonstrates how to generate a SAN certificate without making a permanent change to the openssl configuration.

Generate a list of all required DNS names, (Note: CN will be discarded).

$ export SAN="DNS:www.domain.localdomain,DNS:domain.localdomain"
@jdeathe
jdeathe / centos-wildcard-certbot.md
Last active November 29, 2021 10:33
Installation and Usage of Certbot on CentOS to Obtain a Let’s Encrypt Wildcard TLS/SSL Certificate.

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 / cloud-config-docker-el7.yml
Last active April 6, 2021 13:29
Cloud-Init user-data to install Docker on CentOS-7
#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-----