Snippets

Sysadmin Snippets

strace all PHP-FPM processes

strace -f $(pidof php-fpm | sed 's/\([0-9]*\)/\-p \1/g')

Process memory in MB + process path

ps aux  | awk '{print $6/1024 " MB\t\t" $11}'  | sort -n

Top hit URIs from nginx log

cat access.log | awk '{print $7}' | sort | uniq -c | sort -nr | awk '{print $1, $2}' | head -n 20

Server Config Snippets

nginx Security Headers

# Security Headers
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Xss-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;

WP-CLI Snippets

#!/bin/bash

# Which domain should passwords be reset for?
domain="strategiq.co"

# Loop over all matching user accounts.
for email in $(wp user list --field=user_email --skip-plugins --skip-themes)
do
if [[ $email == *"$domain"* ]]; then
pass=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32}`
wp user update $email --skip-email --user_pass="$pass" --quiet --skip-plugins --skip-themes
fi
done