# Problem to install logstash using deb file on ubuntu 16.0.4

**URL:** <https://discuss.elastic.co/t/problem-to-install-logstash-using-deb-file-on-ubuntu-16-0-4/121092>\
**Category:** Logstash\
**Created:** [February 22, 2018, 4:53pm UTC](https://discuss.elastic.co/t/problem-to-install-logstash-using-deb-file-on-ubuntu-16-0-4/121092 "2018-02-22T16:53:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arab.Soheyl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arab.soheyl/32/28068_2.png) [@Arab.Soheyl](https://discuss.elastic.co/u/Arab.Soheyl)\
**Post date:** [February 22, 2018, 4:53pm UTC](https://discuss.elastic.co/t/problem-to-install-logstash-using-deb-file-on-ubuntu-16-0-4/121092/1 "2018-02-22T16:53:17Z")

</div>

I have an ubuntu server 16.0.4. I was installed elastic and kibana (both 6.2.2) with Debian file package. Now I want to install logstash 6.2.2 with .deb file, but some error occurred.

```
elk@elk:~$sudo dpkg --install logstash-6.2.2.deb
(Reading database ... 130938 files and directories currently installed.)
Preparing to unpack logstash-6.2.2.deb ...
Unpacking logstash (1:6.2.2-1) over (1:6.2.2-1) ...
Setting up logstash (1:6.2.2-1) ...
could not find java; set JAVA_HOME or ensure java is in PATH
chmod: cannot access '/etc/default/logstash': No such file or directory
dpkg: error processing package logstash (--install):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 logstash

```

but java was installed on this machine before and JAVA\_HOME variable was set.

```
elk@elk:~$ java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

elk@elk:~$ echo $JAVA_HOME
/usr/local/java/jdk1.8.0_162

```

What is the problem??

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 22, 2018, 5:16pm UTC](https://discuss.elastic.co/t/problem-to-install-logstash-using-deb-file-on-ubuntu-16-0-4/121092/2 "2018-02-22T17:16:07Z")

</div>

Does `sudo java -version` work or does `sudo env | grep jAVA_HOME` return the expected results?

---

<div class="post-metadata">

**Author:** ![Arab.Soheyl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arab.soheyl/32/28068_2.png) [@Arab.Soheyl](https://discuss.elastic.co/u/Arab.Soheyl)\
**Post date:** [February 22, 2018, 5:24pm UTC](https://discuss.elastic.co/t/problem-to-install-logstash-using-deb-file-on-ubuntu-16-0-4/121092/3 "2018-02-22T17:24:15Z")

</div>

This is the Result.

```
elk@elk:~$ sudo java -version
sudo: java: command not found
elk@elk:~$ sudo env | grep jAVA_HOME
elk@elk:~$

```

But I Try this way:

```
sudo vi /etc/environment

```

At the end of this file, I add the following line

```
JAVA_HOME="/usr/local/java/jdk1.8.0_162" 

```

Save and exit the file, and reload it.

```
source /etc/environment 

```

After this way I got a new error:

```
elk@elk:~$ sudo dpkg --install logstash-6.2.2.deb
Selecting previously unselected package logstash.
(Reading database ... 116903 files and directories currently installed.)
Preparing to unpack logstash-6.2.2.deb ...
Unpacking logstash (1:6.2.2-1) ...
Setting up logstash (1:6.2.2-1) ...
Using provided startup.options file: /etc/logstash/startup.options
/usr/share/logstash/vendor/jruby/bin/jruby: line 401: /usr/bin/java: No such file or directory
Unable to install system startup script for Logstash.
chmod: cannot access '/etc/default/logstash': No such file or directory
dpkg: error processing package logstash (--install):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 logstash
```

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 22, 2018, 9:54pm UTC](https://discuss.elastic.co/t/problem-to-install-logstash-using-deb-file-on-ubuntu-16-0-4/121092/4 "2018-02-22T21:54:24Z")

</div>

Not sure what's up here. I'd have to dig into the startup scripts and I don't have time for that. Can't you just install the JVM from a regular Debian package?

---

<div class="post-metadata">

**Author:** ![Arab.Soheyl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arab.soheyl/32/28068_2.png) [@Arab.Soheyl](https://discuss.elastic.co/u/Arab.Soheyl)\
**Post date:** [February 23, 2018, 7:38am UTC](https://discuss.elastic.co/t/problem-to-install-logstash-using-deb-file-on-ubuntu-16-0-4/121092/5 "2018-02-23T07:38:13Z")

</div>

I have not Internet on the remote server! my connection is over vpn.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 23, 2018, 7:46am UTC](https://discuss.elastic.co/t/problem-to-install-logstash-using-deb-file-on-ubuntu-16-0-4/121092/6 "2018-02-23T07:46:46Z")

</div>

So copy the .deb file(s) over the VPN and install it?

---

<div class="post-metadata">

**Author:** ![Arab.Soheyl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arab.soheyl/32/28068_2.png) [@Arab.Soheyl](https://discuss.elastic.co/u/Arab.Soheyl)\
**Post date:** [February 23, 2018, 4:08pm UTC](https://discuss.elastic.co/t/problem-to-install-logstash-using-deb-file-on-ubuntu-16-0-4/121092/7 "2018-02-23T16:08:38Z")

</div>

Yes, I did it. This Problem occurred when I wanted to install Logsatsh with deb file.

---

<div class="post-metadata">

**Author:** ![Arab.Soheyl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arab.soheyl/32/28068_2.png) [@Arab.Soheyl](https://discuss.elastic.co/u/Arab.Soheyl)\
**Post date:** [February 24, 2018, 8:38pm UTC](https://discuss.elastic.co/t/problem-to-install-logstash-using-deb-file-on-ubuntu-16-0-4/121092/9 "2018-02-24T20:38:33Z")

</div>

and finally,  
I found my problem! on this result of installation:

```
elk@elk:~$ sudo dpkg --install logstash-6.2.2.deb
Selecting previously unselected package logstash.
(Reading database ... 116903 files and directories currently installed.)
Preparing to unpack logstash-6.2.2.deb ...
Unpacking logstash (1:6.2.2-1) ...
Setting up logstash (1:6.2.2-1) ...
Using provided startup.options file: /etc/logstash/startup.options
/usr/share/logstash/vendor/jruby/bin/jruby: line 401: /usr/bin/java: No such file or directory
Unable to install system startup script for Logstash.
chmod: cannot access '/etc/default/logstash': No such file or directory
dpkg: error processing package logstash (--install):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 logstash

```

this problem and some else basically for java! you can change java path on /etc/logstash/startup.options and run installation command again, it will be ok but some problem will arise!

My Solution:  
I have installed java manually in /usr/local/java/.... but logstash by default read /usr/bin/java to use java.  
to do it I use this guide to install java and run logstash installation command again. it works well.

```
wget http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-i586.tar.gz
sudo mkdir /usr/lib/jvm
cd /usr/lib/jvm
sudo tar -xvzf ~/Downloads/jdk-8u151-linux-x64.tar.gz
vi /etc/environment

```

Add this line to environment

```
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/jdk1.8.0_151/bin:/usr/lib/jvm/jdk1.8.0_151/db/bin:/usr/lib/jvm/jdk1.8.0_151/jre/bin"
J2SDKDIR="/usr/lib/jvm/jdk1.8.0_151"
J2REDIR="/usr/lib/jvm/jdk1.8.0_151/jre"
JAVA_HOME="/usr/lib/jvm/jdk1.8.0_151"
DERBY_HOME="/usr/lib/jvm/jdk1.8.0_151/db"

```

then save it and close. after that run this commands:

```
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_151/bin/java" 0 
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_151/bin/javac" 0 
sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_151/bin/java 
sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_151/bin/javac

reboot
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 24, 2018, 8:38pm UTC](https://discuss.elastic.co/t/problem-to-install-logstash-using-deb-file-on-ubuntu-16-0-4/121092/10 "2018-03-24T20:38:40Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
