Last active
January 1, 2017 08:50
-
-
Save shaikh-shahid/d9c15391fb3a22bd71de544513ed73b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Go to DigitalOcean and <a href="https://m.do.co/c/31513addbd1b" target="_blank">login</a> to your account, create one if not already. | |
Create new Droplet ( Server ) and choose latest Ubuntu. Refer the image below for reference. | |
<img src="https://codeforgeek.com/wp-content/uploads/2016/12/dropet-1024x517.gif" alt="digitalocean droplet" width="640" height="323" class="aligncenter size-large wp-image-2763" /> | |
DigitalOcean will create new Droplet and send you an e-mail containing the credentials to log-in your Server. You can use <strong>SSH</strong> or putty ( For Windows User ) to login to your Server. | |
Once you are logged on, do the system update first using the following command. | |
<code>sudo apt-get update</code> | |
Now we need to install Java first, this is the only dependencies ElasticSearch needs. | |
Here is the command to Install Java run time system in your Server. | |
<code> | |
sudo apt-get install default-jre | |
sudo apt-get install default-jdk | |
</code> | |
Depending upon your ElasticSearch version, you may need Java version 8. You can install same using following list of commands. | |
<code> | |
sudo add-apt-repository ppa:webupd8team/java | |
sudo apt-get update | |
sudo apt-get install oracle-java8-installer | |
</code> | |
Next, let's download ElasticSearch. You can download any version you like. Here is the command. | |
<code> | |
wget | |
https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/x.x.x/elasticsearch-2.3.1.deb | |
</code> | |
Replace <strong>x.x.x</strong> with version number. For example, 5.1.1. | |
Once it is downloaded, we can install it using the following command. | |
<code> | |
sudo dpkg -i elasticsearch-2.3.1.deb | |
</code> | |
In order to access ElasticSearch as command, run following in your terminal. | |
<code> | |
sudo systemctl enable elasticsearch.service | |
</code> | |
Now start ElasticSearch using the following command. | |
<code> | |
sudo systemctl start elasticsearch | |
</code> | |
This will start the ElasticSearch. We can check whether installation went right using the following command. | |
<code> | |
curl localhost:9200 | |
</code> | |
You should be seeing the similar response as shown below. | |
<img src="https://codeforgeek.com/wp-content/uploads/2016/12/Screen-Shot-2016-12-09-at-4.20.44-PM.png" alt="ElasticSearch running on DigitalOcean" width="756" height="285" class="aligncenter size-full wp-image-2765" /> | |
Awesome! | |
To make it available via URL, we need a reverse proxy Server. Let's install and configure Nginx as a reverse proxy. | |
Execute the following command on the terminal to install Nginx. | |
<code> | |
sudo apt-get update | |
sudo apt-get install nginx | |
</code> | |
Once install, switch to Nginx directory using the following command. | |
<code> | |
cd /etc/nginx/conf.d/ | |
</code> | |
Create new configuration file using the following command. | |
<code> | |
nano elastic.conf | |
</code> | |
Copy and paste following code. | |
<code> | |
server { | |
listen 80; | |
server_name <IP or domain>; | |
access_log /var/log/nginx/elastic.log; | |
client_max_body_size 10G; | |
location / { | |
proxy_pass http://localhost:9200; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Forwarded-Proto $scheme; | |
proxy_buffering off; | |
} | |
} | |
</code> | |
At <b>server_name</b> either put the IP or sub-domain if available. Save the file using <b>CTRL+S</b> command and restart Nginx using the following command. | |
<code>sudo systemctl nginx restart</code> | |
Now you can access ElasticSearch using the browser by typing your IP or sub-domain. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment