Install and configure PHP + NGINX for Ubuntu 18.04

How to install and configuration NGINX with PHP.

It’s really simple.

Install NGINX and php-fpm

apt install nginx php-fpm

Then add this configuration to the NGINX site with which you want to enable PHP.

 location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }

 

This configuration will usually be added in /etc/nginx/sites-enabled/default

or the global configuration in /etc/nginx/nginx.conf

 

References:
https://devanswers.co/installing-php-nginx-ubuntu-18-04/
https://linuxize.com/post/how-to-install-php-on-ubuntu-18-04/

 

Meteor get Collections by Reference

This short code sample will show you how to get access to a Collection by reference.

The root variable is essentially referencing the this global but detects the correct global reference based on where the client is running.

var colData = function (collectionName) {

var root = Meteor.isClient ? window : global;

var col = root[collectionName];

return col.find().fetch();
}
colData('Things');

 

References:
https://dweldon.silvrback.com/collections-by-reference

Iron Router Multiple Data Context with Meteor

Here’s how to do it:

Router.route('/things', {

    name: 'things',    

    waitOn: function () {

        return [this.subscribe('thing'),this.subscribe('thinga')];

    },

    data: function () {

        return {

            thing: Thing.find(),

            thinga: Thinga.findOne({type: "abc"})

        };

    },

    onAfterAction: function () {

        Meta.setTitle('Things');

    }

});

To access the data context in the Template use the following syntax:

console.log('Template.instance().data.thinga.propertyname', Template.instance().data.thinga.propertyname);

 

References:

https://iron-meteor.github.io/iron-router/

Set Fn key to always on with Apple keyboard

If you’re using an Apple keyboard with Linux and want to use the Function keys normally, for example F2 to rename files, it’s possible to do so with a simple modification.

Open a terminal and run this command:

sudo -s 'echo 2 > /sys/module/hid_apple/parameters/fnmode'

If you want something other than Function keys taking precedence there are other options.

The following are the accepted values:

  • 0 = disabled : Disable the ‘fn’ key. Pressing ‘fn’+’F8’ will behave like you only press ‘F8’
  • 1 = fkeyslast : Function keys are used as last key. Pressing ‘F8’ key will act as a special key. Pressing ‘fn’+’F8’ will behave like a F8.
  • 2 = fkeysfirst : Function keys are used as first key. Pressing ‘F8’ key will behave like a F8. Pressing ‘fn’+’F8’ will act as special key (play/pause)

 

References:

https://superuser.com/questions/79822/how-to-swap-the-fn-use-of-function-keys-on-an-apple-keyboard-in-linux/1141657

How to Fix Ubuntu Landscape – Invalid Machine token

Ubuntu Landscape allows you to keep systems updated when deployed in large clusters.

If you clone a machine and look in its logs you might find an error message similar to the ones below.

Error message:

during refresh: cannot check: cannot send status to server: bad server status 403 (URL: https://livepatch.canonical.com/api/machine/dfb8755a82202da0678c99065c9501ab): {"error": "Invalid Machine Token"}

You may also see this warning in the motd.

 * Canonical Livepatch is enabled.
- Livepatch server check failed.
Please see /var/log/syslog for more information.

 

The solution is to remove, reinstall landscape and register the node again with your license key.

apt remove landscape-common 
apt install landscape-common

It’s not clear if this is a bug or intended behavior for Landscape.

For large deploymens this could be problematic.

Fix slow GUI, sluggish interface with Mint Cinnamon

 

If you have been using your system heavily, with multiple workspaces, various applications that are not entirely memory efficient, these combined factors can lead to your interface feeling sluggish.

In order to resolve this issue without having to restart the entire system issue this command in a terminal windows to restart mind and preserve your workspaces and windows.

pkill -HUP -f "cinnamon --replace"

 

References:
https://askubuntu.com/questions/143838/how-do-i-restart-cinnamon-from-the-tty