This is a text-only version of the following page on https://raymii.org:
---
Title       :   Install the latest ZNC from source on Ubuntu
Author      :   Remy van Elst
Date        :   25-10-2013
URL         :   https://raymii.org/s/tutorials/Install_the_Lastest_ZNC_from_Source_in_Ubuntu.html
Format      :   Markdown/HTML
---



This tutorial will show you how to install the latest (1.0) version of ZNC (an
advanced IRC bouncer) on Ubuntu from source. Why from source? The package in the
repositories is quite old and missing features like multiple IRC networks. It
also includes an upstart script, and an example config for ZNC. ZNC is an
advanced IRC bouncer that is left connected so an IRC client can
disconnect/reconnect without losing the chat session.

<p class="ad"> <b>Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below:</b><br><br> <a href="https://leafnode.nl">I'm developing an open source monitoring app called  Leaf Node Monitoring, for windows, linux & android. Go check it out!</a><br><br> <a href="https://github.com/sponsors/RaymiiOrg/">Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.</a><br><br> <a href="https://www.digitalocean.com/?refcode=7435ae6b8212">You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $100 credit for 60 days. </a><br><br> </p>


This is tested on Ubuntu 12.04 and 13.10. It will probably work on debian, only
you will have to use an init script instead of an upstart script.

### Note about checkinstall and packages

We are using checkinstall here to create a debian package of the source we
compile. I do this because it gives more flexibility in managing the software
afterwards. Upgrading or uninstalling the packages is easier than removing all
the things make install placed. Furthermore, it makes it more clear for other
administrators which software is installed.

If you for example want to upgrade znc when it was installed via this tutorial
with checkinstall, repeat the tutorial with only the version number changed.

### Install required packages

We first need to make sure we have all the packages required to build ZNC.
Install them via apt:



   sudo apt-get install build-essential libssl-dev libperl-dev pkg-config checkinstall


### Compile ZNC

Now we are going to get and compile ZNC itself. First download the source code:



   cd /usr/local/src
   sudo wget http://znc.in/releases/znc-latest.tar.gz


Extract it and move into the folder:



   sudo tar -xzvf znc-latest.tar.gz
   cd znc*


Start the actual compilation:



   ./configure
   make
   checkinstall


For checkinstall, the default answers to the questions are good.

### ZNC User

Create a separate ZNC user so that ZNC does not need to run as root:



   sudo groupadd znc
   sudo adduser --system --home /var/lib/znc --group znc


### Configuring ZNC

You can use the interactive wizard to configure ZNC. I advise you to do this, it
helps a lot when creating the initial configuration file:



   sudo -u znc /usr/local/bin/znc --datadir=/var/lib/znc --makeconf


You can find my example config at the bottom of the tutorial.

### Upstart script

Place the following script in `/etc/init/znc.conf` to be able to start and stop
znc as a system service:



   # znc

   description "IRC Bouncer"

   start on runlevel [2345]

   stop on runlevel [016]

   respawn
   respawn limit 10 5
   setuid znc

   script
     exec /usr/local/bin/znc --datadir=/var/lib/znc -f
   end script


Save it, then you can start and stop znc like so:



   sudo start znc
   sudo stop znc


### Example ZNC configuration

This is an example ZNC configuration file. You can place this in
`/var/lib/znc/configs/znc.conf`. Make sure to stop ZNC first:



   // WARNING
   //
   // Do NOT edit this file while ZNC is running!
   // Use webadmin or *controlpanel instead.
   //
   // Buf if you feel risky, you might want to read help on /znc saveconfig and /znc rehash.
   // Also check http://en.znc.in/wiki/Configuration

   AnonIPLimit = 10
   ConnectDelay = 5
   LoadModule = partyline
   MaxBufferSize = 500
   ProtectWebSessions = true
   SSLCertFile = /var/lib/znc/znc.pem
   ServerThrottle = 30
   Version = 1.0

   &lt;Listener listener0&gt;
     AllowIRC = true
     AllowWeb = false
     IPv4 = true
     IPv6 = true
     Port = 6667
     SSL = true
   &lt;/Listener&gt;

   &lt;User Example&gt;
     Admin = true
     AltNick = Example_
     AppendTimestamp = false
     AutoClearChanBuffer = false
     Buffer = 500
     ChanModes = +stn
     DenyLoadMod = false
     DenySetBindHost = false
     Ident = Example
     JoinTries = 10
     LoadModule = chansaver
     LoadModule = controlpanel
     LoadModule = perform
     MaxNetworks = 3
     MultiClients = true
     Nick = Example
     PrependTimestamp = true
     QuitMsg = So long and thanks for all the fish!
     RealName = Example
     StatusPrefix = *
     TimestampFormat = [%H:%M:%S]

     &lt;Network freenode&gt;
       FloodBurst = 4
       FloodRate = 1.00
       IRCConnectEnabled = true
       LoadModule = chansaver
       LoadModule = keepnick
       LoadModule = kickrejoin
       LoadModule = nickserv
       LoadModule = perform
       Server = irc.freenode.net 6667

       &lt;Chan #ansible&gt;
       &lt;/Chan&gt;

       &lt;Chan #digitalocean&gt;
       &lt;/Chan&gt;

       &lt;Chan #logstash&gt;
       &lt;/Chan&gt;

       &lt;Chan #lowendbox&gt;
       &lt;/Chan&gt;

       &lt;Chan #raspberrypi&gt;
       &lt;/Chan&gt;

       &lt;Chan #reddit-sysadmin&gt;
       &lt;/Chan&gt;

       &lt;Chan #sixgun&gt;
       &lt;/Chan&gt;

       &lt;Chan #ubuntu&gt;
       &lt;/Chan&gt;

       &lt;Chan #vpsboard&gt;
       &lt;/Chan&gt;

       &lt;Chan #wordpress&gt;
       &lt;/Chan&gt;

       &lt;Chan #znc&gt;
       &lt;/Chan&gt;
     &lt;/Network&gt;

   &lt;/User&gt;


With this config file set up, you can point your IRC client to the ZNC server's
IP and port (6667) and automatically be connected to Freenode and a few
channels.

### Troubleshooting

If stuff doesn't work, try running ZNC like this:



   sudo -u znc /usr/local/bin/znc --datadir=/var/lib/znc -f


It will give very clear and verbose errors about what is going wrong.

  [1]: https://www.digitalocean.com/?refcode=7435ae6b8212

---

License:
All the text on this website is free as in freedom unless stated otherwise.
This means you can use it in any way you want, you can copy it, change it
the way you like and republish it, as long as you release the (modified)
content under the same license to give others the same freedoms you've got
and place my name and a link to this site with the article as source.

This site uses Google Analytics for statistics and Google Adwords for
advertisements. You are tracked and Google knows everything about you.
Use an adblocker like ublock-origin if you don't want it.

All the code on this website is licensed under the GNU GPL v3 license
unless already licensed under a license which does not allows this form
of licensing or if another license is stated on that page / in that software:

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

Just to be clear, the information on this website is for meant for educational
purposes and you use it at your own risk. I do not take responsibility if you
screw something up. Use common sense, do not 'rm -rf /' as root for example.
If you have any questions then do not hesitate to contact me.

See https://raymii.org/s/static/About.html for details.