Ubuntu: Install Elasticsearch as Docker Container and manage it nicely in GUI

Submitted by Peter Majmesku on Fri, 12/09/2016 - 14:16

Install Docker

Firstly install Docker via this article: https://docs.docker.com/engine/installation/linux/ubuntulinux/. Mind to setup the user and group permissions according to the article. So that you are able to start Docker as non-root user.

Check your user's group setting

Make sure that a group with the name "docker" exists and your user is a member of that group. To add a user to an existing group, execute the following command:

sudo usermod -a -G groupName userName

After your user (mine f.e. is "peter") is being successfully added into the "docker" group, logout and login to ensure that you are acting from the docker user group.

Install Kitematic

Dowload the Kitematic GUI for Docker Debian package via https://github.com/docker/kitematic/releases. This program will empower you, to manage your Docker containers easily via a graphical user interface. Mind that this application is currently beta. Then install it by

sudo dpkg -i dist/Kitematic_0.12.9_amd64.deb
Kitematic - GUI for Docker

Install Elasticsearch as Docker Container by Kitematic

Follow the following steps in Kitematic:

  1. Hit the "New"-Button
  2. Search for "elasticsearch" to see the official Elasticsearch Docker Container in the search result list
  3. Choose the version you want via the tag (version 1.7.2 is the version which works for me)
  4. Hit the button which is labeled with "Create". Kitematic will now install the Elasticsearch Docker container for you.
Kitematic Elasticsearch installation

GUI for Elasticsearch: Jettro

To be able to execute easily queries within Elasticsearch, check status etc., you can install Jettro (https://github.com/jettro/elasticsearch-gui). Just execute the following command inside your Elasticsearch Docker container to install the Elasticsearch plugin:

bin/plugin install jettro/elasticsearch-gui 

Jettro - GUI for Elasticsearch inside the webbrowser

Start the Docker Container automatically on system startup as a Daemon

An official tutorial about this can be found here: https://docs.docker.com/engine/admin/host_integration/. In particular, you can follow the steps below.

Create a file at 


with the following content:

Description=Elasticsearch container

ExecStart=/usr/bin/docker start -a elasticsearch
ExecStop=/usr/bin/docker stop -t 2 elasticsearch


Now reload the daemon:

sudo systemctl daemon-reload

Start the Elasticsearch Docker container as a service:

sudo systemctl start docker-elasticsearch.service

Enable the service at system startup:

sudo systemctl enable docker-elasticsearch.service

Voilà! Happy search index querying. (:

Disable IPv6 on Ubuntu Linux and Windows 10

Submitted by Peter Majmesku on Wed, 12/07/2016 - 19:57

I had this issue with "sudo apt update" or at trying to install something with composer in the WSL. The issue has been connected with IPv6. So I have disabled IPv6 and the requests where working much faster.

In Ubuntu (not Windows 10) disable IPv6 that way: Add the following lines at the bottom of /etc/sysctl.conf:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Run sudo sysctl -p to reload the /etc/sysctl.conf settings.

To disable IPv6 only for apt-get:

sudoedit /etc/apt/apt.conf.d/99force-ipv4

Put the following contents in it:

Acquire::ForceIPv4 "true";

Save the file, and you're good to go. If you want to force IPv6 instead, change the 4 to 6 in the file name and settings. To choose between one of them, test with the fast method and see which works better.

In Windows 10 I could fix my issue for the Bash by the execution of a small program from Microsoft: https://support.microsoft.com/en-us/kb/929852


Use multiple PHP versions on Ubuntu 16.10 with Apache 2 and in the CLI

Submitted by Peter Majmesku on Thu, 11/10/2016 - 16:55

I needed an easy ability to switch multiple PHP versions on my local development environment. This ability should include the command line interface and webserver components of PHP. Here I am sharing my findings with you. I guess that this functionality is not new on Ubuntu 16.10. Most probably you can use the features already on Ubuntu 16.04 (LTS version) also.

You can use multiple PHP versions with one Apache server. Easily install them via the Apt package manager by the famous PPA from Ondrej. Then you can install multiple PHP versions like so:

sudo apt install php7.1 php5.6 php7.0

For being able to switch the PHP versions within the Apache webserver, you need the Lib Apache packages. You can install them like so:

sudo apt install libapache2-mod-php7.0
sudo apt install libapache2-mod-php7.1
sudo apt install libapache2-mod-php5.6

Afterwards you are able to switch the PHP version, which is being executed by Apache. E.g.:

sudo a2dismod php7.0
sudo a2enmod php5.6
sudo service apache2 restart

To switch he PHP CLI version, you can use the "update-alternatives" command. This command let's choose you the various versions of your program. In the background it will create symlinks for you. For getting into the version chooser dialogue, execute the following command:

sudo update-alternatives --config php

To switch PHP extensions for a specific PHP version, you can use the "phpenmod" and "phpdismod" commands. For enabling the Xdebug PHP extension for PHP 7.0, use the following command:

sudo phpenmod -v 7.0 xdebug

Installing free of charge SSL certificate from Letsencrypt.org in Apache 2 webserver on Ubuntu 14.04

Submitted by Peter Majmesku on Mon, 08/29/2016 - 20:57

SSL certificates are cost-free nowadays. Letsencrypt.org is providing a service which lets you get SSL certificates that are free and work in the common web browsers. The following commands must be executed on the same machine on which your webserver is running. Because letsencrypt.org must be allowed to access it. Download the certbot from letsencrypt.org and make the binary executable:

wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto

Now temporary stop your Apache server, to download the certificates.

sudo service apache2 stop

Now run the certbot program to download the certificates:

./certbot-auto certonly

This program leads you trough a short form process within your terminal. Asking you for the domain you want to secure.

Mind the SSL certificate renewal

The SSL certificate is valid for 3 months. You will get notified about this via the terminal output from the certbot. It looks like this, if you have executed the "./certbot-auto certonly" command at 23.07.2016:

 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/my-domain.com/fullchain.pem. Your cert will
   expire on 2016-10-21. To obtain a new or tweaked version of this
   certificate in the future, simply run certbot-auto again. To
   non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - If you like Certbot, please consider supporting our work by:
   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

There's an automatic way to accomplish the renewal. You can add this line to your crontab, to automatically re-new the certificates:

30 4 1 * * sudo service apache2 stop && ./certbot-auto renew --standalone && sudo service apache2 start

Enable the SSL certificate on your web server

Enable SSL in your Apache setup:

sudo a2enmod ssl

Now as you have the certificates, you can integrate them in your Apache 2 VHost configuration at /etc/apache2/sites-available/. Change "example.com" to your domain name.

 SSLEngine on
   SSLCertificateFile    /etc/letsencrypt/live/example.com/cert.pem
   SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
   SSLCertificateChainFile /etc/letsencrypt/live/example.com/fullchain.pem 

Switch the virtual host port from 80 to 443. For this set the following in your Vhost configuration file: 

<VirtualHost *:80>


 <VirtualHost *:443>

Small tweak for SEO

Search engines expect that a web page can be accessed by only one address on your website. To redirect all requests from http to https and ensure that only http://your-domain.com will be requested and not http://your-domain.com "and" http://www.your-domain.com, you can setup the redirect within your VHost file. Add this to the top of the configuration file for your virtual host: 

# Redirect all requests to SSL and ensure www. subdomain is re-directed, too.

<VirtualHost *:80>

ServerName your-domain.com

Redirect / https://your-domain.com/


<VirtualHost *:80>

ServerName www.your-domain.com

Redirect / https://your-domain.com/


<VirtualHost *:443>


Now restart Apache and happy SSL usage: 

sudo service apache2 restart

A complete Apache2 Vhost config file example:

<VirtualHost *:80>
ServerName example.com
Redirect / https://example.com

<VirtualHost *:80>
ServerName www.example.com
Redirect / https://example.com

<VirtualHost *:443>
ServerName example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/example.com/web

SSLEngine on
SSLCertificateFile /etc/ssl-cert/live/example.com/cert.pem
SSLCertificateKeyFile /etc/ssl-cert/live/example.com/privkey.pem
SSLCertificateChainFile /etc/ssl-cert/live/example.com/fullchain.pem

<Directory /var/www/example.com/web>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

Subscribe to Ubuntu