title: How to install and run elasticsearch in Vagrant?
body: <p>I'm trying to install and run Elasticsearch in Vagrant. The issue is that when I try to run elasticsearch I get the following error:</p>
  
  <pre><code>    log4j:ERROR setFile(null,true) call failed.
  java.io.FileNotFoundException: /home/vagrant/elasticsearch-2.3.0/logs/elasticsearch.log (No such file or directory)
      at java.io.FileOutputStream.open0(Native Method)
      at java.io.FileOutputStream.open(FileOutputStream.java:270)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:213)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:133)
      at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
      at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
      at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
      at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
      at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
      at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
      at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
      at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
      at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
      at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
      at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
      at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
      at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
      at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
  log4j:ERROR Either File or DatePattern options are not set for appender [file].
  log4j:ERROR setFile(null,true) call failed.
  java.io.FileNotFoundException: /home/vagrant/elasticsearch-2.3.0/logs/elasticsearch_deprecation.log (No such file or directory)
      at java.io.FileOutputStream.open0(Native Method)
      at java.io.FileOutputStream.open(FileOutputStream.java:270)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:213)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:133)
      at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
      at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
      at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
      at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
      at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
      at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
      at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
      at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
      at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:672)
      at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)
      at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
      at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
      at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
      at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
  log4j:ERROR Either File or DatePattern options are not set for appender [deprecation_log_file].
  log4j:ERROR setFile(null,true) call failed.
  java.io.FileNotFoundException: /home/vagrant/elasticsearch-2.3.0/logs/elasticsearch_index_indexing_slowlog.log (No such file or directory)
      at java.io.FileOutputStream.open0(Native Method)
      at java.io.FileOutputStream.open(FileOutputStream.java:270)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:213)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:133)
      at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
      at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
      at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
      at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
      at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
      at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
      at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
      at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
      at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:672)
      at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)
      at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
      at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
      at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
      at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
  log4j:ERROR Either File or DatePattern options are not set for appender [index_indexing_slow_log_file].
  log4j:ERROR setFile(null,true) call failed.
  java.io.FileNotFoundException: /home/vagrant/elasticsearch-2.3.0/logs/elasticsearch_index_search_slowlog.log (No such file or directory)
      at java.io.FileOutputStream.open0(Native Method)
      at java.io.FileOutputStream.open(FileOutputStream.java:270)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:213)
      at java.io.FileOutputStream.&lt;init&gt;(FileOutputStream.java:133)
      at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
      at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
      at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
      at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
      at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
      at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
      at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
      at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
      at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:672)
      at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)
      at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
      at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
      at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:243)
      at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
  log4j:ERROR Either File or DatePattern options are not set for appender [index_search_slow_log_file].
  Exception in thread "main" java.lang.IllegalStateException: Unable to access 'path.plugins' (/home/vagrant/elasticsearch-2.3.0/plugins)
  Likely root cause: java.nio.file.AccessDeniedException: /home/vagrant/elasticsearch-2.3.0/plugins
      at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
      at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
      at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
      at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
      at java.nio.file.Files.createDirectory(Files.java:674)
      at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781)
      at java.nio.file.Files.createDirectories(Files.java:767)
      at org.elasticsearch.bootstrap.Security.ensureDirectoryExists(Security.java:337)
      at org.elasticsearch.bootstrap.Security.addPath(Security.java:314)
      at org.elasticsearch.bootstrap.Security.addFilePermissions(Security.java:246)
      at org.elasticsearch.bootstrap.Security.createPermissions(Security.java:212)
      at org.elasticsearch.bootstrap.Security.configure(Security.java:118)
      at org.elasticsearch.bootstrap.Bootstrap.setupSecurity(Bootstrap.java:196)
      at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:167)
      at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)
      at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
  </code></pre>
  
  <p>I think the problem is that it has no write permission. When I do install elastic through provision I get the following permissions:</p>
  
  <pre><code>drwxr-xr-x 2 root    root     4096 Apr  3 09:26 bin
  drwxr-xr-x 2 root    root     4096 Apr  3 09:26 config
  drwxr-xr-x 2 root    root     4096 Apr  3 09:26 lib
  -rw-rw-r-- 1 vagrant vagrant 11358 Jan 27 12:53 LICENSE.txt
  drwxrwxr-x 5 vagrant vagrant  4096 Mar 29 08:04 modules
  -rw-rw-r-- 1 vagrant vagrant   150 Jan 27 12:53 NOTICE.txt
  -rw-rw-r-- 1 vagrant vagrant  8700 Jan 27 12:53 README.textile
  </code></pre>
  
  <p>But when I do the same manually:</p>
  
  <pre><code>drwxrwxr-x 2 vagrant vagrant  4096 Apr  2 18:20 bin
  drwxrwxr-x 2 vagrant vagrant  4096 Apr  2 18:20 config
  drwxrwxr-x 2 vagrant vagrant  4096 Apr  2 18:20 lib
  -rw-rw-r-- 1 vagrant vagrant 11358 Jan 27 12:53 LICENSE.txt
  drwxrwxr-x 5 vagrant vagrant  4096 Mar 29 08:04 modules
  -rw-rw-r-- 1 vagrant vagrant   150 Jan 27 12:53 NOTICE.txt
  -rw-rw-r-- 1 vagrant vagrant  8700 Jan 27 12:53 README.textile
  </code></pre>
  
  <p>My Vagrantfile is:</p>
  
  <pre><code>Vagrant.configure(2) do |config|
    config.vm.box = "hashicorp/precise64"
    config.vm.network "private_network", ip: "192.168.33.10"
  
    config.vm.provision "shell", inline: &lt;&lt;-SHELL
      sudo apt-get update
      sudo apt-get install software-properties-common python-software-properties -y
      sudo apt-add-repository ppa:webupd8team/java
      sudo apt-get update
      echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
      sudo apt-get install oracle-java8-installer -y -q
      wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.0/elasticsearch-2.3.0.tar.gz
      tar -xzf elasticsearch-*.tar.gz
      mv elasticsearch-2.3.0 elasticsearch
      rm elasticsearch-*
    SHELL
  end
  </code></pre>