In this tutorial we will show you how to install ELK Stack on Ubuntu 18.04 LTS. For those of you who didn’t know, ELK stack is a popular, open source log management platform. It is used as a centralized management for storing, analyzing and viewing of logs. Centralized management makes it easier to study the logs and identify issues if any for any number of servers.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation ELK Stack on an Ubuntu 18.04 Bionic Beaver server.
Install ELK Stack on Ubuntu 18.04 LTS Bionic Beaver
Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.
Step 2. Installing Java on Ubuntu 18.04 LTS.
Now install the Java by using the following command:
Next, you can also set the JAVA_HOME and other defaults by installing oracle-java8-set-default:
Then, You can now verify if the JAVA_HOME variable is set by running:
Verify the Java version:
[email@example.com~]# java -version
First, install Elasticsearch using the apt package manager from the official Elastic repository:
wget-qO-https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo"deb http://packages.elastic.co/elasticsearch/2.x/debian stable main"|sudotee-a/etc/apt/sources.list.d/elasticsearch-2.x.list
Then, install Elasticsearch with apt using the following command:
Start the Elasticsearch service and set it to automatically start on boot:
Elasticsearch is now installed. Edit it’s configurations now, using following commands:
First, create the Kibana source list:
echo"deb http://packages.elastic.co/kibana/4.5/debian stable main"|sudotee-a/etc/apt/sources.list.d/kibana-4.5.x.list
Now install Kibana with this command:
Once the installation is completed, open the kibana.yml file and restrict the remote access to the Kibana instance:
# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
Start the Kibana service and set it to start automatically on boot:
First, create the Logstash source list:
echo'deb http://packages.elastic.co/logstash/2.2/debian stable main'|sudotee/etc/apt/sources.list.d/logstash-2.2.x.list
Next, Install Logstash using the apt package manager:
Once the Logstash package is installed start the Logstash service and set it to start automatically on boot:
Next, use Nginx as a reverse proxy to access Kibana from the public IP address. To install Nginx, run:
Create a basic authentication file with the openssl command:
echo"admin:`openssl passwd -apr1 YourPasswd`"|sudotee-a/etc/nginx/htpasswd.kibana
Then, create a virtual host configuration file for the Kibana instance:
Creating a symbolic link and test the Nginx configuration:
Restart the Nginx service and set it to start automatically on boot:
You can now access the kibana interface by opening your browser and typing:
Congratulation’s! You have successfully installed ELK Stack. Thanks for using this tutorial for installing ELK Stack on your Ubuntu 18.04 LTS Bionic Beaver. For additional help or useful information, we recommend you to check the official ELK Stack web site.