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 / centos-6-redis-php-session-handler.md
Last active July 30, 2022 21:24
CentOS-6 - Redis PHP Session Save Handler
@jdeathe
jdeathe / using-xdebug-to-profile-a-php56u-vagrant-host.md
Last active September 20, 2018 15:07
Using Xdebug to Profile PHP on a Vagrant VM.

Using Xdebug to Profile a Vagrant VM.

These instructions are for profiling a PHP application running on a CentOS-6 remote host using the php56u php 5.6 packages from an OSX local host.

On remote

Install Xdebug for php56u.

# yum -y install \
@jdeathe
jdeathe / telnet-memcached.exp
Last active June 7, 2017 21:21
Expect script to test memcached using telnet.
#!/usr/bin/env expect
set env(HOME) /usr/local/bin
set env(SHELL) /bin/bash
set env(TERM) xterm
set timeout 3
# Destination IP address
set HOST [lindex ${argv} 0]
@jdeathe
jdeathe / telnet-proxy-tcp4.exp
Last active June 7, 2017 21:22
Expect script to test PROXY protocol requests using telnet.
#!/usr/bin/env expect
set env(HOME) /usr/local/bin
set env(SHELL) /bin/bash
set env(TERM) xterm
set timeout 15
# Source IP address
set SOURCE_ADDRESS [lindex ${argv} 0]
@jdeathe
jdeathe / maintenance.html
Last active February 12, 2018 23:42
Simple HTML Maintenance Page
<!DOCTYPE html>
<html>
<head>
<title>Maintenance</title>
<style>
body{color:#666;background-color:#f1f1f1;font-family:sans-serif;margin:12%;max-width:50%;}
h1,h2{color:#333;font-size:4rem;font-weight:400;text-transform:uppercase;}
h2{color:#333;font-size:2rem;}
p{font-size:1.5rem;}
</style>
@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 / 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-compose.yml
Last active March 14, 2017 05:54
docker-compose definition for a Wordpress environment with SSH access
# Requirement: https://github.com/jdeathe/centos-ssh/issues/472
#
# On CentOS-7 Host install docker-compose:
# sudo yum -y upgrade python*
# sudo yum -y install epel-release
# sudo yum -y install python-pip
# sudo pip install docker-compose
# OR Use container alias and add the following 2 environment variables to .env
# Ref: https://gist.github.com/jdeathe/e7b09222bb44a2efa6a67b893fe35ac1
#
@jdeathe
jdeathe / socat-ngrok-route.md
Last active February 22, 2017 14:01
Share an internal https (encrypted) host with a publicly accessible URL using http (unencrypted) using socat and ngrok.

Test an Internal HTTPS Host using HTTP on a Public Network.

Limitations

This does not rewrite URLs like a reverse proxy but can be useful for viewing a single page.

Install tools

socat

@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"