Skip to main content

Misc Issue

Low Ram

Enable 2GB swap , if you see the services are being killed

fallocate -l 2G /swapfile
dd if=/dev/zero of=/swapfile bs=1M count=2048
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

Also make the number of child workes 2x the amout of RAM in www-data pool of php-fpm .

Home Path

To set home for user - inside public_html create .bash_profile inside the file put the home path as

echo "export HOME='/srv/www/my.writetextfast.com/home/'" >> ~/home/bash_profile

Cleanup

Find largest file -

find -type f -exec du -Sh {} + | sort -rh | head -n 5

Cleanup snaps folder

snap list --all | while read snapname ver rev trk pub notes; do if [[ $notes = *disabled* ]]; then snap remove "$snapname" --revision="$rev"; fi; done

Resize allocated disk

tune2fs -m1 /dev/sda

Optimize images

find . -type f -iname "*.jpg" -exec jpegoptim --max=85 --strip-all --all-progressive --preserve-perms -p {} +

Clear comments

// Delete comments
wp comment delete $(wp comment list --status=spam --format=ids) --force

// Delete Pending
wp comment delete $(wp comment list --status=hold --format=ids) --force

No log but critial

Create a debug backtrace in mu-plugins , this will dump all messages -

add_filter(
'wp_php_error_message',
function( $message, $error ) {
        debug_print_backtrace();
        return $message;
},
10,
2
);

IPTables Dumpe

If you wish to reset ip tables to default. [Stackhttps://serverfault.com/a/1042478]

iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
#Then flush the rules:
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD

Random dump

If you wisht o find where files are outputting code

$locations = [];
ob_start(function($buffer) {
  global $locations;
  $locations[] = debug_backtrace();
  return $buffer;
}, 1);

-- code --

print_r($locations);