How to install Elasticsearch in Linux Ubuntu server

I am currently working on three computers and it is real pain to get everything synchronized. Of course I am using git repositories and cloud but I still have to get rid of apache server, databases, etc. So I decided to create Virtual Machine which I save on USB drive and try to do it this way.

The Linux installation with Apache and MySql is not a problem. But I needed to install Elasticsearch ( which runs on Java ) and make it accessible from my computer ( Linux with Elasticsearch is running in VM ).

Configuration

Change network host and allow remote connection

Open Elasticsearch configuration file in your favorite editor, allow and change network.host to localhost. And if you want to connect to Elasticsearch from remote machine you need to enable network.bind_host and set it to 0.

sudo vi /etc/elasticsearch/elasticsearch.yml

Part of my Elasticsearch configuration file :

############################## Network And HTTP ###############################
# Elasticsearch, by default, binds itself to the 0.0.0.0 address, and listens
# on port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node
# communication. (the range means that if the port is busy, it will automatically
# try the next port).
# Set the bind address specifically (IPv4 or IPv6):
#
network.bind_host: 0
# Set the address other nodes will use to communicate with this node. If not
# set, it is automatically derived. It must point to an actual IP address.
#
#network.publish_host: 192.168.0.1
# Set both ‘bind_host’ and ‘publish_host’:
#
network.host: localhost

Restart Elasticsearch service

sudo /etc/init.d/elasticsearch restart

Conclusion

Now, you should be able to connect and get data from Elasticsearch. Test it with command :