Install APCu PHP extension on RunCloud

# Install the required developement tools apt install autoconf libpcre3-dev # Set module name MODULE_NAME=”apcu” # Set download version MODULE_VERSION=”5.1.18″ # Download & Extract wget https://pecl.php.net/get/$MODULE_NAME-$MODULE_VERSION.tgz tar -zxvf $MODULE_NAME-$MODULE_VERSION.tgz cd $MODULE_NAME-$MODULE_VERSION # Set PHP version PHPRC_VERSION=”php74rc” # Installing for PHP

Install nano editor latest version (Build from source)

VERSION=4.8 wget https://www.nano-editor.org/dist/v4/nano-${VERSION}.tar.gz tar xf nano-${VERSION}.tar.gz rm -f nano-${VERSION}.tar.gz cd nano-${VERSION} ./configure make sudo make install cd .. sudo rm -rf /usr/local/src/nano-* sudo mv nano-${VERSION} /usr/local/src touch ~/.nanorc nano ~/.nanorc # Enable syntax higlighting include “/usr/local/share/nano/*.nanorc”  

Install tmux latest version on Ubuntu 16.04/18.04

sudo apt install automake build-essential pkg-config libevent-dev libncurses5-dev -y VERSION=3.0a wget https://github.com/tmux/tmux/releases/download/${VERSION}/tmux-${VERSION}.tar.gz tar xf tmux-${VERSION}.tar.gz rm -f tmux-${VERSION}.tar.gz cd tmux-${VERSION} ./configure make sudo make install cd .. sudo rm -rf /usr/local/src/tmux-* sudo mv tmux-${VERSION} /usr/local/src sudo killall -9 tmux rm

Fix slow Ethernet performance on Intel i218/i219 NIC

Some of the Hetzner servers comes with Intel i218/i219 ethernets. Linux kernel version 4.15 or later may cause slowness of download/upload speed on those NIC.  I was supposed to get 1 Gbps upload but only getting 500 Mbps. To fix

Install pigz (Parallel Implementation of GZip)

pigz, which stands for Parallel Implementation of GZip, is a fully functional replacement for gzip that exploits multiple processors and multiple cores to the hilt when compressing data. pigz is approx 10x faster than regular GZip. For Ubuntu 16.04 or

Install latest version of RAR in Linux

Run as root. wget https://www.rarlab.com/rar/rarlinux-x64-5.8.0.tar.gz tar -xf rarlinux-x64-5.8.0.tar.gz cd rar chmod +x rar unrar mv rar unrar /usr/bin mv rarfiles.lst /etc wget -O rarreg.key https://pastebin.com/raw/Ed7iQSPm mv default.sfx rarreg.key /usr/local/lib cd .. rm -r rar rm rarlinux-x64-5.8.0.tar.gz bash  

Install Ookla Speedtest on Linux

export INSTALL_KEY=379CE192D401AB61 export DEB_DISTRO=$(lsb_release -sc) apt-key adv –keyserver keyserver.ubuntu.com –recv-keys $INSTALL_KEY echo “deb https://ookla.bintray.com/debian ${DEB_DISTRO} main” | tee /etc/apt/sources.list.d/speedtest.list apt update && apt install gnupg1 apt-transport-https dirmngr speedtest ln -s /usr/bin/speedtest /usr/local/bin/spd

Better PHP exec() & Things to remember

/** * Run command, get output and exit code. */ function run_command($command) { $output = []; exec($command, $output, $exitcode); // Trim, Remove empty strings, then Reset keys. $output = array_values(array_filter(array_map(‘trim’, $output), function($string) { return $string !== ”; })); return [$output,

Read STDOUT and STDERR in non blocking way on proc_open

<?php // The command to run. $command = ‘ping 127.0.0.1’; $descriptors = [ 0 => [‘pipe’, ‘r’], // STDIN 1 => [‘pipe’, ‘w’], // STDOUT 2 => [‘pipe’, ‘w’], // STDERR ]; $process = proc_open($command, $descriptors, $pipes); if (is_resource($process)) {

Manage WSL like a boss with LxRunOffline

Download LxRunOffline from Github and add it to the PATH so it can be accessible from anywhere. Download Ubuntu form the links below, then extract the .zip file. # Ubuntu 16.04 https://aka.ms/wsl-ubuntu-1604 # Ubuntu 18.04 https://aka.ms/wsl-ubuntu-1804 To install Ubuntu 16.04

Real time flushing in PHP on Nginx

Works perfectly on RunCloud’s Native Nginx Stack. @ini_set(‘zlib.output_compression’, 0); @ini_set(‘output_buffering’, ‘Off’); @ini_set(‘implicit_flush’, true); @ob_implicit_flush(1); @ob_end_clean(); header(‘Content-Encoding: none’); header(‘X-Accel-Buffering: no’);

Remove image sizes in WordPress

/** * Function to Remove image size. * @param [string] $size */ function remove_image_size_by_size($size) { $dimension = explode(‘x’, $size); global $_wp_additional_image_sizes; foreach ($_wp_additional_image_sizes as $key => $single) { if ($single[‘width’] == $dimension[0] && $single[‘height’] == $dimension[1]) { remove_image_size($key); break; }

Change default PHP CLI configuration on RunCloud

Runcloud allows you to change the PHP Settings for each application from their Web Panel. But if you’re like me who heavily uses the PHP-CLI then changing config from Web Panel won’t help you. The PHP configs from their Web

Handful WP-CLI Tricks

Delete posts based on search # Spaces needs replace with + (plus sign) # Eg: hello+world wp post delete $(wp post list –post_type=’post’ –s=’keyword+here’ –format=ids) –force