How To: Install OTRS 4.0.2 from Source on FreeBSD 10.1 (with ZFS, MySQL56, Apache24)

After dealing with OTRS Help Desk on Ubuntu Server for a couple of years (which actually worked quite well for our small IT firm!), I've finally decided to migrate this great Help Desk platform over to FreeBSD, simply because I love it! I'm no FreeBSD master, but I've figured out just enough to get this working. So here we go...

~Alex

Step 1: Pre Installation Tasks

(Assuming you have a new FreeBSD 10.1 installation with ZFS. Which I've installed on MS Hyper-V Server 2012 R2.)

Edit /etc/rc.conf and verify the hostname of your FreeBSD/OTRS server as well as the static IP address. Which may look something like this:
Code:
# Networking
hostname="OTRS"
ifconfig_de0="inet 192.168.1.20 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
sshd_enable="YES"
zfs_enable="YES"
apache24_enable="YES"
mysql_enable="YES"

Don't forget to visit /etc/resolv.conf and enter your DNS

Fetch the ports tree:
Code:
> portsnap fetch && portsnap extract

Install the port pkg:
Code:
> cd /usr/ports/ports-mgmt/pkg/ && make install clean
> pkg2ng

Install applications needed to run OTRS:
Code:
> pkg install apache24
> pkg install mysql56-server

Step 2. Let's prepare the MySQL56-Server

Start MySQL Server:
Code:
> service mysql-server start

Set the root password for MySQL:
Code:
> mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('rootpass');
mysql> quit
That was easy!

Step 3. Prepare the OTRS Directory and Download/Extract the Source

Remember, we are using ZFS which is great for snapshots/backups. Create a ZFS partition for OTRS:
Code:
> zfs create zroot/opt
> zfs set mountpoint=/opt zroot/opt
(I use the default OTRS directory because I do not want to go through the headache of modifying the OTRS script files.)

Fetch the OTRS source using wget and rename the OTRS directory:
Code:
> cd /opt
> fetch ftp://ftp.otrs.org/pub/otrs/otrs-4.0.2.tar.gz
> tar -xf otrs-4.0.2.tar.gz
> mv otrs-4.0.2 otrs

Add the OTRS user to the system:
Code:
> adduser
UserName = otrs
FullName = otrs
Home Directory = /opt/otrs
Password = otrs

Now let's copy some configuration files:
Code:
> cd /opt/otrs/Kernel
> cp Config.pm.dist Config.pm
> cp Config/GenericAgent.pm.dist Config/GenericAgent.pm

Set OTRS permissions/access rights:
Code:
> perl /opt/otrs/bin/otrs.SetPermissions.pl --otrs-user=otrs --web-group=www --admin-group=otrs

If the obove doesn't work, your can temporarily set permissions ...

Code:
> chown -R otrs /opt/otrs/
> chgrp -R otrs /opt/otrs/
> chmod -R 777 /opt/otrs/

Step 4. Perl

See which Perl Modules are needed to run OTRS on FreeBSD: # perl /opt/otrs/bin/otrs.CheckModules.pl.

Use the following commands to install the missing required modules:
Code:
> cpan Archive::Zip
> cpan Date::Format
> cpan DBI
> cpan DBD::mysql
> cpan Net::DNS
> cpan Template (Enable Stash and XS during install.)
> cpan Template::Stash::XS
> cpan YAML::XS

Double check the installed Perl Modules to verify installation:
Code:
>perl /opt/otrs/bin/otrs.CheckModules.pl
If you didn't miss anything, all required modules should show "OK".

Verify Perl has been properly set up:
Code:
> perl -cw /opt/otrs/bin/cgi-bin/index.pl
/opt/otrs/bin/cgi-bin/installer.pl syntax OK
> perl -cw /opt/otrs/bin/cgi-bin/customer.pl
/opt/otrs/bin/cgi-bin/customer.pl syntax OK
> perl -cw /opt/otrs/bin/otrs.PostMaster.pl
/opt/otrs/bin/otrs.PostMaster.pl syntax OK

Step 5. Configure Apache24

Start the Apache24 service to verify if the base install is working

Code:
> service apache24 start

Open a browser window to the IP address of your FreeBSD server. In my case http://192.168.1.20/ If you see "It works!" in the browser, your Apache24 pkg install went well.

Copy the OTRS configuration file to the Apache24 directory:
Code:
> cp /opt/otrs/scripts/apache2-httpd.include.conf /usr/local/etc/apache24/otrs.conf

Create an alias within the Apache24 configuration file. Add the following line to the bottom of the Apache24 configuration file httpd.conf:
Code:
> vi /usr/local/etc/apache24/httpd.conf
Include etc/apache24/otrs.conf

Also, verify that the CGI module is loaded. Locate
Code:
#LoadModule cgi_module libexec/apache22/mod_cgi.so
within httpd.conf and uncomment the line (remove the #). Save and exit.

Restart the Apache24 service:
Code:
> service apache24 restart

Step 6. Copy/Rename OTRS cron .dist files

Code:
> cd /opt/otrs/var/cron
> mv aaa_base.dist aaa_base
> mv cache.dist cache
> mv fetchmail.dist fetchmail
> mv generate_dashboard_stats.dist generate_dashboard_stats
> mv generic_agent-database.dist generic_agent-database
> mv generic_agent.dist generic_agent
> mv pending_jobs.dist pending_jobs
> mv postmaster.dist postmaster
> mv postmaster_mailbox.dist postmaster_mailbox
> mv rebuild_ticket_index.dist rebuild_ticket_index
> mv scheduler_watchdog.dist scheduler_watchdog
> mv session.dist session
> mv unlock.dist unlock

Make sure OTRS cron jobs are running as the OTRS user:
Code:
> su otrs
> /opt/otrs/bin/Cron.sh start

Step 7. You're ready to launch! Configure the MySQL database for OTRS 4.x

Open your web browser and navigate to the URL http://ServerIPAddress/otrs/installer.pl.


Step 8. Once the OTRS MySQL database has been configured, lets create a script to automate the ZFS snapshot for /opt

Create a script called "SnapshotOTRS.sh" and placed it into the /root directory
Code:
#!/bin/sh
zfs snapshot -r zroot/opt@otrs_`date +%Y%m%d_%H%M%S`

My script also includes the ability to backup a MySQL dump as well as export the entire OTRS folder & snapshots to an smb share (or external drive if needed).

Make script executable
Code:
> chmod +x /root/SnapShotOTRS.sh

Create a cronjob to run this script daily at 6pm
Code:
> crontab -e

*    18    *    *    * /root/SnapshotOTRS.sh


This should get OTRS up and running in FreeBSD. Hope this was helpful.
 
Last edited by a moderator:
Thank you! As I can see the FreeBSD port of OTRS is at version 3.3.7 while you install the newer version 4.x. You might contact the port's maintainer and could help him upgrading the port to the latest version.
 
Thank you! As I can see the FreeBSD port of OTRS is at version 3.3.7 while you install the newer version 4.x. You might contact the port's maintainer and could help him upgrading the port to the latest version.

Sure, I'd be glad to help with that.
 
I hate to bump this old thread but I'm killing myself trying to get OTRS running in a jail on my FreeNAS box.

I've followed this guide very closely however I went ahead and installed otrs-4.0.9.tar.gz

My issue is that upon trying to access the server, xxx.xxx.xxx.xxx/otrs/installer.pl I get this

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at you@example.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.


And my httpd-error.log shows this

Code:
[client 192.168.11.95:50459] AH01215: (2)No such file or directory: exec of '/opt/otrs/bin/cgi-bin/installer.pl' failed: /opt/otrs/bin/cgi-bin/installer.pl
[Wed Aug 05 16:29:50.953114 2015] [cgi:error] [pid 44061] [client 192.168.11.95:50459] End of script output before headers: installer.pl

I've done a lot of searching and tried several things but no luck.

Anyone have ideas?
 
For Jails (here sysutils/ezjail):

/etc/sysctl.conf
Code:
security.jail.allow_raw_sockets=1

Ezjail config for the jail:
Code:
export jail_otrs_parameters="allow.raw_sockets=1 allow.sysvipc=1"
security.jail.allow_raw_sockets=1

Not sure if both options are needed or just the sysvipc

This should also solve the FreeNAS problem above. AFAIK every application/server is a separate jail in FreeNAS.
 
I hate to bump this old thread but I'm killing myself trying to get OTRS running in a jail on my FreeNAS box.

I've followed this guide very closely however I went ahead and installed otrs-4.0.9.tar.gz

My issue is that upon trying to access the server, xxx.xxx.xxx.xxx/otrs/installer.pl I get this



And my httpd-error.log shows this

Code:
[client 192.168.11.95:50459] AH01215: (2)No such file or directory: exec of '/opt/otrs/bin/cgi-bin/installer.pl' failed: /opt/otrs/bin/cgi-bin/installer.pl
[Wed Aug 05 16:29:50.953114 2015] [cgi:error] [pid 44061] [client 192.168.11.95:50459] End of script output before headers: installer.pl

I've done a lot of searching and tried several things but no luck.

Anyone have ideas?

Hi David,

Did Langschlaefer solution help? I haven't worked much with jails, therefore I wouldn't know where to start.
 
Last edited by a moderator:
I hate to bump this old thread but I'm killing myself trying to get OTRS running in a jail on my FreeNAS box.

I've followed this guide very closely however I went ahead and installed otrs-4.0.9.tar.gz

My issue is that upon trying to access the server, xxx.xxx.xxx.xxx/otrs/installer.pl I get this



And my httpd-error.log shows this

Code:
[client 192.168.11.95:50459] AH01215: (2)No such file or directory: exec of '/opt/otrs/bin/cgi-bin/installer.pl' failed: /opt/otrs/bin/cgi-bin/installer.pl
[Wed Aug 05 16:29:50.953114 2015] [cgi:error] [pid 44061] [client 192.168.11.95:50459] End of script output before headers: installer.pl

I've done a lot of searching and tried several things but no luck.

Anyone have ideas?

I ran into the same error when updating my OTRS server. I think this will fix the problem.

# cd /usr/bin/perl
# ln /usr/local/bin/perl


The OTRS config files are looking for perl in /usr/bin. In FreeBSD 10.2, it seems to be in /usr/local/bin. So I created a link which solved the problem.
 
I ran into the same error when updating my OTRS server. I think this will fix the problem.

# cd /usr/bin/perl
# ln /usr/local/bin/perl


The OTRS config files are looking for perl in /usr/bin. In FreeBSD 10.2, it seems to be in /usr/local/bin. So I created a link which solved the problem.

It should be ln -s /usr/local/bin/perl /usr/bin/perl

This was a change from the way Perl is installed, see /usr/ports/UPDATING ( less -p 20150513 /usr/ports/UPDATING to get right to it)
 
Last edited by a moderator:
Back
Top