# Run Kibana as service on CentOS

**URL:** <https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971>\
**Category:** Kibana\
**Created:** [June 19, 2015, 9:09am UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971 "2015-06-19T09:09:03Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![MattStibbs](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MattStibbs](https://discuss.elastic.co/u/MattStibbs)\
**Post date:** [June 19, 2015, 9:09am UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/1 "2015-06-19T09:09:03Z")

</div>

Hi there,

I am trying to get Kibana up and running on Centos. Following the instructions on the elastic site, I can successfully download the files and run in the console.

But is there any guidance anywhere that helps me get this set up to run as a service for a production environment?

Any help appreciated.

Matt

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 20, 2015, 1:31am UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/2 "2015-06-20T01:31:34Z")

</div>

We're working on that, as part of providing KB4 packages.

In the meantime it's pretty simple to build an init script to handle it, just copy an existing one and modify it 🙂

---

<div class="post-metadata">

**Author:** ![MattStibbs](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MattStibbs](https://discuss.elastic.co/u/MattStibbs)\
**Post date:** [June 23, 2015, 9:53am UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/3 "2015-06-23T09:53:26Z")

</div>

OK - thanks! 😄

---

<div class="post-metadata">

**Author:** ![jcollie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jcollie/32/567_2.png) [@jcollie](https://discuss.elastic.co/u/jcollie)\
**Post date:** [June 23, 2015, 3:10pm UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/4 "2015-06-23T15:10:00Z")

</div>

Here's the systemd service file I'm using on my CentOS 7 systems for Kibana 4.1:

```
[Unit]
Description=Kibana 4

[Service]
Type=simple
User=logstash
Environment=CONFIG_PATH=/etc/kibana/kibana.yml
Environment=NODE_ENV=production
ExecStart=/opt/kibana-{{ kibana_version }}/node/bin/node /opt/kibana-{{ kibana_version }}/src/bin/kibana.js

[Install]
WantedBy=multi-user.target
```

---

<div class="post-metadata">

**Author:** ![jcollie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jcollie/32/567_2.png) [@jcollie](https://discuss.elastic.co/u/jcollie)\
**Post date:** [June 23, 2015, 3:50pm UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/5 "2015-06-23T15:50:56Z")

</div>

Here's the service file that I use on CentOS 7 to run Kibana 4.1:

```
[Unit]
Description=Kibana 4

[Service]
Type=simple
User=logstash
Environment=CONFIG_PATH=/etc/kibana/kibana.yml
Environment=NODE_ENV=production
ExecStart=/opt/kibana-4.1.0/node/bin/node /opt/kibana-4.1.0/src/bin/kibana.js

[Install]
WantedBy=multi-user.target
```

---

<div class="post-metadata">

**Author:** ![MattStibbs](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MattStibbs](https://discuss.elastic.co/u/MattStibbs)\
**Post date:** [June 23, 2015, 5:42pm UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/7 "2015-06-23T17:42:13Z")

</div>

Thank you - this is working great 😄

---

<div class="post-metadata">

**Author:** ![jcollie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jcollie/32/567_2.png) [@jcollie](https://discuss.elastic.co/u/jcollie)\
**Post date:** [June 23, 2015, 6:09pm UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/8 "2015-06-23T18:09:11Z")

</div>

For the record, you'd put it into "/etc/systemd/system/kibana.service". Whenever changing systemd unit files it's a good idea to do:

systemctl daemon-reload

Then you can start the service with:

systemctl start kibana

---

<div class="post-metadata">

**Author:** ![MattStibbs](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MattStibbs](https://discuss.elastic.co/u/MattStibbs)\
**Post date:** [June 24, 2015, 7:03am UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/9 "2015-06-24T07:03:28Z")

</div>

Thanks Jeffrey 🙂

---

<div class="post-metadata">

**Author:** ![KIVagant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kivagant/32/7182_2.png) [@KIVagant](https://discuss.elastic.co/u/KIVagant)\
**Post date:** [January 15, 2016, 8:48am UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/10 "2016-01-15T08:48:23Z")

</div>

Hello, Jeffrey.

I'm trying to run Kibana with [this setup guide](https://www.elastic.co/guide/en/beats/libbeat/1.0.1/getting-started.html#logstash-input-update)

In this case I don't have file src/bin/kibana.js in extracted folder. How I can register the systemctl service with /opt/kibana-4.3.1/bin/kibana run command?

Thank you

**Up:** OK. I'm already found [this init script](https://raw.githubusercontent.com/cjcotton/init-kibana/master/kibana) with [instruction](http://stackoverflow.com/questions/32068692/running-kibana-4-as-a-service-in-centos).

---

<div class="post-metadata">

**Author:** ![jcollie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jcollie/32/567_2.png) [@jcollie](https://discuss.elastic.co/u/jcollie)\
**Post date:** [January 19, 2016, 2:31pm UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/11 "2016-01-19T14:31:49Z")

</div>

Elastic changed things around in the latest releases. If you'd prefer a native systemd unit file (and who wouldn't!) here's my current one:

> [Unit]  
> Description=Kibana 4

> [Service]  
> Type=simple  
> User=logstash  
> Environment=CONFIG\_PATH=/etc/kibana/kibana.yml  
> Environment=NODE\_ENV=production  
> ExecStart=/opt/kibana/4.3.1/node/bin/node /opt/kibana/4.3.1/src/cli

> [Install]  
> WantedBy=multi-user.target

---

<div class="post-metadata">

**Author:** ![KIVagant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kivagant/32/7182_2.png) [@KIVagant](https://discuss.elastic.co/u/KIVagant)\
**Post date:** [January 19, 2016, 4:27pm UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/12 "2016-01-19T16:27:57Z")

</div>

Thank's again, Jeffrey.

I'll try to check your new config.

---

<div class="post-metadata">

**Author:** ![bibl2008](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@bibl2008](https://discuss.elastic.co/u/bibl2008)\
**Post date:** [June 8, 2016, 9:47am UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/13 "2016-06-08T09:47:05Z")

</div>

Hello Jeffrey,  
Can you help for adding this service to autorun for kibana service start after a system was reboot?

---

<div class="post-metadata">

**Author:** ![rafal](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@rafal](https://discuss.elastic.co/u/rafal)\
**Post date:** [July 4, 2016, 3:00am UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/14 "2016-07-04T03:00:16Z")

</div>

Hi there,

I am not sure if this is still valid discussion, if not please just delete this post.

If you are interested in systemd, this is how I do it (including start after a reboot).

1. /opt/kibana is a symbolic link to /opt/kibana-4.5.1-1  
which makes it very easy to upgrade/downgrade (you can create kibana\_current) if you are using rpm/deb packages.

2. rsyslog (default in Redhat) /etc/rsyslog.d/kibana.conf:

$umask 0000  
$fileOwner kibana  
$dirOwner kibana  
$dirCreateMode 0755  
$fileCreateMode 0444

if $programname == 'kibana' and $syslogfacility-text == 'local7' /var/log/kibana/kibana.log

1. Systemd file: /etc/systemd/system/kibana.service

[Unit]  
Description=Kibana  
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]  
Type=simple  
User=kibana  
Environment=NODE\_ENV=production  
Environment=CONFIG\_PATH=/opt/kibana/config/kibana.yml  
EnvironmentFile=/etc/default/kibana  
WorkingDirectory=/opt/kibana/  
ExecStart=/opt/kibana/bin/../node/bin/node --max-old-space-size=512 /opt/kibana/bin/../src/cli  
StandardOutput=syslog  
StandardError=syslog  
SyslogFacility=local7  
SyslogLevel=notice  
SyslogIdentifier=kibana  
Restart=on-failure

[Install]  
WantedBy=multi-user.target

1. then enable in systemd:  
systemctl enable kibana
2. and finally start kibana:  
systemctl start kibana
3. and optionally check the status:  
systemctl status kibana

\*please execute all commands as root

1. Optionally you can add logrotate to rotate the log file under /var/log/kibana/kibana.log

I hope it helps!

Cheers,  
Rafal.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 4, 2016, 3:16am UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/15 "2016-07-04T03:16:00Z")

</div>

The latest versions of KB all come with an init script.

---

<div class="post-metadata">

**Author:** ![rafal](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@rafal](https://discuss.elastic.co/u/rafal)\
**Post date:** [July 4, 2016, 6:32pm UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/16 "2016-07-04T18:32:02Z")

</div>

Hi Mark,

I agree,

- but how do you get logs from in a separate place (not 'messages')?
- you cannot easily pass NODE\_OPTIONS because /opt/kibana/bin/kibana is not including it, you have to add at the end but before 'exec': [-r /etc/default/kibana] && . /etc/default/kibana

---

<div class="post-metadata">

**Author:** ![Just-Insane](https://avatars.discourse-cdn.com/v4/letter/j/9f8e36/32.png) [@Just-Insane](https://discuss.elastic.co/u/Just-Insane)\
**Post date:** [November 24, 2016, 5:49pm UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/17 "2016-11-24T17:49:57Z")

</div>

Old topic, I know. If I should create a new topic, please let me know.

I am trying to get kibana to output logs to /var/log/kibana/kibana.log so that I can process the http response codes better (using logstash filters), however, I can't get kibana to load after editing kibana.yml. It works when I use /opt/kibana/bin/kibana, and the logs go to the correct file, however, when I try to use the systemd file that comes with kibana, systemd says that everything is working fine, but I am unable to get kibana to load at all.

Using kibana 4.4.2 on CentOS 7

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 24, 2016, 8:42pm UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/18 "2016-11-24T20:42:51Z")

</div>

> [@Just-Insane](#):
>
> If I should create a new topic, please let me know.

Please do.

---

<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:** [July 6, 2017, 1:33pm UTC](https://discuss.elastic.co/t/run-kibana-as-service-on-centos/23971/19 "2017-07-06T13:33:58Z")

</div>


