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 If Ubuntu 18.04 then view Change timezone Source: timedatectl set-timezone Asia/Kolkata # or use dpkg-reconfigure tzdata Change hostname

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:// 0xF1656F24C74CD1D8 add-apt-repository ‘deb [arch=amd64,arm64,i386,ppc64el] 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: 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 16.04

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

Tweaking Mail-in-a-Box

Disable greylisting Disabling greylisting helps to receive emails without any delay. touch /etc/postgrey/whitelist_clients.local nano /etc/postgrey/whitelist_clients.local Then add # Don’t greylist any domain. /.*/ Save and Exit, then enter commands: service postgrey restart service postfix restart Source:

Tweaking WSL (Windows Subsystem for Linux)

Change apt mirrors (India only) # Create backup first sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup # Download modified sources.list wget # Replace sudo mv sources.list /etc/apt/ Fix files/folder permissions Add some useful aliases cd && touch .bash_aliases add below lines

Get all system IPv4 addresses as array in PHP

/** * Get system ipv4 addresses. * Works on Linux only. * @return [array] */ function getSystemIPs() { $ips = shell_exec(‘hostname -I’); $ips = preg_split(‘/\s+/’, $ips, -1, PREG_SPLIT_NO_EMPTY); foreach ($ips as $ip) { if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE |

Use Rocket-Nginx under RunCloud

Login as root then enter following commands. cd /etc/nginx-rc git clone cd rocket-nginx cp rocket-nginx.ini.disabled rocket-nginx.ini php rocket-parser.php As of version 2.1.1 there is a typo in the rocket-nginx.ini , change media_header to medias_header My template: Create file {app-name}.location.main-before.rocket.conf

Upgrade cURL to latest version on Ubuntu

Tested on Ubuntu 16.04 only. Login as root then do the following: mkdir latestcurl cd latestcurl apt build-dep curl If E: Unable to find a source package for curl error appears then do the following otherwise skip the below part. sed