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

Reset IPMI password

Worked for me on Ubuntu 16.04 ipmitool user list ipmitool user set password <user id from list> <new password>

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

Fix CMD output when using shell_exec() from PHP

/** * Fix weird output encoding. */ function run_command($command) { $string = shell_exec($command); $string = mb_convert_encoding($string, ‘UTF-8’, ‘UTF-16LE’); return $string; } Source: https://www.reddit.com/r/PHPhelp/comments/de27u8/why_output_of_shell_exec_is_different/f2uwy7s

Linux touch command for Windows

Create touch.cmd with the following content and it to ENV Path. @echo off setlocal enableextensions disabledelayedexpansion (for %%a in (%*) do if exist “%%~a” ( pushd “%%~dpa” && ( copy /b “%%~nxa”+,, & popd ) ) else ( type nul

Things to do after deploying a Ubuntu server

Disable ipv6 Create /etc/sysctl.d/60-ipv6-disable.conf with the following contents: net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 Run service procps restart Change timezone Source: https://askubuntu.com/a/594186 timedatectl set-timezone Asia/Kolkata # or use dpkg-reconfigure tzdata Change hostname To do this read: https://graspingtech.com/change-hostname-ubuntu-16-04/

Tweaking OneSignal WordPress Plugin

/** * Send push based on last active time (Intelligent Delivery). */ add_filter( ‘onesignal_send_notification’, function( $fields ) { $fields[‘delayed_option’] = ‘last-active’; return $fields; }); /** * Always set notification unchecked in post editor. */ add_filter( ‘onesignal_meta_box_send_notification_checkbox_state’, ‘__return_false’ ); /** *

Tweaking cURL

Enter %APPDATA% in Run. Then create file _curlrc with the following content insecure

LEMP stack in WSL

add-apt-repository ppa:nginx/stable add-apt-repository ppa:ondrej/php apt-key adv –recv-keys –keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 add-apt-repository ‘deb [arch=amd64,arm64,i386,ppc64el] http://sgp1.mirrors.digitalocean.com/mariadb/repo/10.2/ubuntu xenial main’ apt update && apt upgrade -y apt install nginx-extras mariadb-server php7.3-fpm php7.3-pdo php7.3-mysql php7.3-zip php7.3-gd php7.3-mbstring php7.3-curl php7.3-xml phpdismod opcache service mysql start mysql_secure_installation

Tweaking WordPress

/** * Logged in for 1 year. */ add_filter( ‘auth_cookie_expiration’, function() { return YEAR_IN_SECONDS; });

Clear cache in WP Rocket when post permalink (slug) changes

To learn more about the issue: https://github.com/wp-media/wp-rocket/issues/1936 Fix: // Fires before an existing post is updated in the database. add_action( ‘pre_post_update’, function( $post_ID, $data ) { // Compare slug, if changed clear cache. if ( get_post_field( ‘post_name’, $post_ID ) !=

Add additional IP addresses to Ubuntu

Login as root then enter command nano /etc/network/interfaces If have something like this on that file iface enp1s0f0 inet static address 123.124.125.40 netmask 255.255.255.0 gateway 123.444.123.1 Then to add additional ips, have it like this iface enp1s0f0 inet static address