But there’s an apt package
Yes. But it kind of sucks. I had problems with the bundled init.d script. It tries to start ejabberd as the user “ejabberd” but something goes awry. It seems to start but I’m then unable to connect to that node using the ejabberdctl command. Maybe its just me? meh.
What about the Process One binary installer?
That works if you’re content with running ejabberd under root user or whatever user you installed ejabberd as. If installed as a user other than root you’ll have a problem trying to start ejabberd with any user other than root. Thats because the .erlang-cookie file is expected in the $HOME directory of the user starting ejabberd. Its a file permissions nightmare. bleh.
Running ejabberd under a safe(r) user account
Install dependencies
Lets use apt to install the dependencies for ejabberd. Its just a shortcut to getting the dependencies. You can do it the hard way. If you want
apt-get build-dep ejabberd
Download ejabberd source
We’ll get the source for ejabberd 2.1.3 the lazy way too. You could of course clone the git repo and checkout version 2.1.3 but a clone can take a while over a slow-w-w-w connection.
wget http://github.com/processone/ejabberd/tarball/v2.1.3 && tar -xzf processone-ejabberd-v2.1.3-0-g962b66b.tar.gz && cd processone-ejabberd-84987d6/src
Creating a user to run ejabberd
This is important. We’ll need it for the ./configure command coming later
sudo groupadd --gid 107 ejabberd
sudo adduser --system --no-create-home --uid 107 --gid 107 --disabled-password --disabled-login ejabberd
Note: I’ve used the same uid and gid in the line above. uid 107 may already be in use on your system. You can check for uid‘s already in use by grep’ing your /etc/passwd. Ensure the numeric value for uid and gid is the same as shown above. I’m not so sure the next step will work as intended if its not.
Configure (with something special), make, make install
Here’s the part that really matters
cd /path-to-untarred-ejabberd/src
sudo ./configure --prefix /usr/local/ejabberd-2.1.3/ --enable-user=ejabberd --enable-odbc --enable-full-xml
sudo make
sudo make install
There are two other options available for the ./configure script. Check this out. You may want MSSQL Server support or whatever. The only must-have for the purpose of this install method is the –enable-user option. The rest can be changed to your liking
The –enable-user option allows ejabberd to be started by root and/or the user account specified. Permissions will be set accordingly by the install process
A sane init.d script
ejabberd is now installed but you’d like it to automatically be started on system startup? You’ll need an init.d script for that and I have one for you.
I mauled the init.d script shipped with Process One‘s binary installer to my liking. Download revised init.d script from github. Place it in your /etc/init.d/ folder naturally. It works. Trust me already
Make ejabberdctl executable from anywhere
This is a lazy hack you could do it “right” by modifying your $PATH env variable in /etc/profile for all users or whatever
sudo ln -s /usr/local/ejabberd-2.1.3/sbin/ejabberdctl /usr/sbin/ejabberdctl
Starting/stopping ejabberd
The ejabberd process will automagically be daemonized erlang-style and the ownership of the ejabberd process is handed over to the ejabberd user we created earlier
root@blahblah:~# /etc/init.d/ejabberd start
Starting ejabberd...
done.
ps aux | grep ejabberd
ejabberd 21200 0.0 19.5 207044 49004 ? Sl 18:07 0:01 /usr/lib/erlang/erts-5.7.4/bin/beam.smp -K true -P 250000 -- -root /usr/lib/erlang -progname erl -- -home /usr/local/ejabberd-2.1.3/var/lib/ejabberd -- -sname ejabberd@localhost -noshell -noinput -noshell -noinput -pa /usr/local/ejabberd-2.1.3/lib/ejabberd/ebin -mnesia dir "/usr/local/ejabberd-2.1.3/var/lib/ejabberd" -s ejabberd -sasl sasl_error_logger {file,"/usr/local/ejabberd-2.1.3/var/log/ejabberd/erlang.log"} -smp auto start
root 21257 0.0 0.2 6152 660 pts/5 S+ 18:37 0:00 grep --color=auto ejabberd
Confirmation that the ejabberd node has been started
root@blahblah:~# ejabberdctl status
The node ejabberd@localhost is started with status: started
ejabberd 2.1.3 is running in that node
And that is all. You could do the same for ejabberd 2.1.4 (I reckon). I didn’t install 2.1.4 because its a little too bleeding edge but you decide for yourself











