OTRS in Nginx using FCGI (multiple users possible)

From OtterHub - OTRS Community Wiki
Jump to: navigation, search

There might be a more up2date version of this how-to here.

OTRS is a very extensive Trouble Ticketing System. It is written in Perl, which has some advantages, but causes some issues performancewise.
One way to deal with it is by running OTRS in Apache with mod_perl. That definitely improves OTRS' performance but introduces another issue. You cannot combine mod_perl with mod_itk, a module to run various sites as various users. If you would choose to run OTRS in mod_perl, you must run all sites as www-data (or the equivalent of your distro).

I've been searching for a solution to run OTRS fast, but with the possibility to run OTRS as a seperate user.
OTRS has thought of the possibility to run it using fcgi, but documentation on howto setup fcgi properly was lacking. Running OTRS as a seperate user seemed to be a challenge.
I finally ended up with Nginx (any other webserver supporting fcgi will probably do fine too), combined with spawn-fcgi. This howto expects you to use Ubuntu and only covers installing OTRS and it's webserver.


  • Software:
Apart from software found in Ubuntu's repositories by default, we also use multiwatch which isn't available in Ubuntu itself, but it does have an apt-repository present. To add it to your system, run:
root@otrs:~# wget -O /etc/apt/sources.list.d/multiwatch.list http://www.tuxis.nl/uploads/howtos/otrs-fcgi/multiwatch.list
root@otrs:~# apt-key adv --keyserver keys.gnupg.net --recv-keys 80121CD2479689D8
root@otrs:~# apt-get update
Now install all software:
root@otrs:~# apt-get install mysql-server nginx spawn-fcgi libnet-dns-perl libio-socket-ssl-perl libnet-ldap-perl libgd-text-perl libgd-graph-perl libpdf-api2-perl libsoap-lite-perl libuser libcgi-fast-perl multiwatch
  • OTRS:
    • Create a new user for OTRS:
root@otrs:~# adduser otrs --disabled-login
Adding user `otrs' ...
Adding new group `otrs' (1001) ...
Adding new user `otrs' (1001) with group `otrs' ...
Creating home directory `/home/otrs' ...
Copying files from `/etc/skel' ...
Changing the user information for otrs
Enter the new value, or press ENTER for the default
       Full Name []: OTRS Webuser
       Room Number []: 
       Work Phone []: 
       Home Phone []: 
       Other []: 
Is the information correct? [Y/n] y
    • Now become the new user and download OTRS. Unpack the archive and make sure that you create a symlink named 'otrs' to the extracted directory. This will make upgrades easier. Also make sure that the file otrs/Kernel/Config.pm exists, and that the path to your OTRS-installation in that file is correct.
root@otrs:~# su - otrs
otrs@otrs:~$ wget http://ftp.otrs.org/pub/otrs/otrs-2.4.7.tar.bz2
otrs@otrs:~$ tar xjvf otrs-2.4.7.tar.bz2
otrs@otrs:~$ ln -s otrs-2.4.7 otrs
otrs@otrs:~$ mv otrs/Kernel/Config.pm.dist otrs/Kernel/Config.pm
    • Edit otrs/Kernel/Config.pm and configure the correct path, in this case "/home/otrs/otrs/"


Spawn-fcgi isn't started upon request. The goal is to achieve better performance, and starting it over and over again isn't very efficient. So we need to start all processes ahead.
You can create your own script to fix that, but you can also download this script, or use it as an inspiration. It will arrange for the users you enter to configure Nginx and the Fcgi-setup. It expects Ubuntu's Upstart so if you're using another operatingsystem, this might not work as expected..

Now run the script for the user you created before. It's possible that the script asks for a hostname for the vhost that will be created:

root@otrs:~# ./ngfcgiotrs otrs
Created upstart config for customer.pl
Created upstart config for index.pl
Created upstart config for installer.pl
Created upstart config for public.pl
Starting service: customer.pl ... index.pl ... installer.pl ... public.pl ... Create vhost-config for otrs.tuxis.net

There is now a upstart job for every file found in the fcgi-bin directory. These will always be running, whether the webserver is running or not. If any of the processes crash, it will automatically be started again. You can find the created files here:

  • /etc/init/otrs/otrs/index.pl.conf
  • /etc/init/otrs/otrs/installer.pl.conf
  • /etc/init/otrs/otrs/customer.pl.conf
  • /etc/init/otrs/otrs/public.conf
  • /etc/nginx/sites-available/<vhost-name>

All that remains is enabling the website and installing OTRS:

root@otrs:~# cd /etc/nginx/sites-enabled/
root@otrs:/etc/nginx/sites-enabled# ln -s ../sites-available/otrs.tuxis.net 
root@otrs:/etc/nginx/sites-enabled# /etc/init.d/nginx restart
Restarting nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
configuration file /etc/nginx/nginx.conf test is successful

OTRS will be running completely after this install. When you need to stop or start any of the fcgi-services, you can do so by typing:

root@otrs:~# stop otrs/$username/index.pl
root@otrs:~# start otrs/$username/index.pl

Where $username is obviously the user for whom you want to restart the service.

installer.pl has an alternative version of the init-script, so it won't start automatically after the install. If you ever need to redo the install or run an upgrade, you can make the installer available by typing:

root@otrs:~# start otrs/$username/installer.pl