Install OTRS With Cpanel

Dont create your support topics here! No new topics with questions allowed!

Moderator: crythias

Forum rules
Dont create your support topics here! No new topics with questions allowed!
Post Reply
handichapped
Znuny newbie
Posts: 1
Joined: 17 Jun 2011, 15:46
Znuny Version: 3.08
Real Name: Brett

Install OTRS With Cpanel

Post by handichapped »

I have a VPS running cpanel that I use for a couple client sites I've done as well as my company site (single person IT shop at the moment). OTRS fit the bill but every document I could possibly find referencing cpanel and OTRS said it couldn't be done or gave instructions for old versions.

First, you need root access. If you don't have it, just stop. You need to make system modifications and unless you have root you won't be able. I used a subdomain off my primary account - you aren't supposed to change the DocumentRoot of your hosted account with cpanel but you can alter the subdomain DocumentRoot.

I had kind of hoped to remove the /otrs/ on the URL once I got things working for a cleaner URL, however I got stuck at one point. Some of these steps are borrowed from this post which details how to remove the /otrs/. I played with them when I got stuck to see if I could get rid of some errors and wanting to document exactly what I did so maybe someone else can follow, I have left these modifications in.

Here are the steps:
  • Grab the latest copy (source) and unpack as the README describes, renaming the unpacked directory so it is located at /opt/otrs. OTRS hardcodes a lot of paths to /opt/otrs. Now that I have it working I might play with moving it out of /opt/otrs. However, start with /opt/otrs (I learned this the hard way).
  • Do not create user account. You will run this with your host account permissions (not root). I could create the account fine in WHM/cpanel, but I couldn't get it to exec even with proper permissions. I had errors in my suexec logs when I tried and the cpanel config files referenced my useraccount in too many places.
  • Setup a subdomain
  • Create the Config.pm and GenericAgent.pm files as the documentation describes.
  • Run the otrs.SetPermissions.pl script as described, but swap out the OTRS user account name and group with your cpanel account name and group (my cpanel username is in a group with the same name). You will need to find your webserver user and group (mine was nobody:nobody).
  • We must change the subdomain's DocumentRoot. Edit the file in /var/cpanel/userdata/(username)/subdomain.domain.com that corresponds to your username and the subdomain you are setting up. Change documentroot: to match /opt/otrs/bin/cgi-bin/
  • It may be possible to change the user and group information to use an OTRS user in the last step, but I didn't want to break my primary domain somehow so I didn't.
  • We need to setup the aliases necessary for apache. Edit /var/local/apache/conf/httpd.conf and look for the section for your subdomain. The last lines details the include files cpanel looks for in its default setup. In my case it's /usr/local/apache/conf/userdata/std/2/(username)/subdomain.domain.com/*.conf
  • Back to the terminal, mkdir -p /usr/local/apache/userdata/std/2/(username)/subdomain.domain.com (this is not created by default, you must create it according to the cpanel docs).
  • Copy the /opt/otrs/scripts/apache2-httpd.include.conf file to /usr/local/apache/userdata/std/2/(username)/subdomain.domain.com
  • Borrowing from the other howto, I tried to edit the copied apache2-httpd.include.conf file to match the given example. However, I couldn't get /scripts/verify_vhost_includes to give an "ok" on the modified config file. I commented out lines one by one and found the perl lines caused issues in my setup. My final apache2-httpd.include.conf file is posted at the end in code. The /scripts/verify_vhost_includes MUST pass, if it fails this will not work.
  • Edit /opt/otrs/var/httpd/htdocs/index.html and modify the second meta line so that the URL references /index.pl (since we are now using the subdomain itself and not /otrs)
  • Run /scripts/rebuildhttpdconf to rebuild your httpd.conf file with the new subdomain DocumentRoot.
  • Run service httpd restart to bounce your web server to pick up the new httpd.conf file.
  • You should be up... if you are lucky :-)
My apache2-httpd.include.conf file (no comments):

Code: Select all

Alias /otrs-web/ "/opt/otrs/var/httpd/htdocs/"
Alias / "/opt/otrs/bin/cgi-bin/"


<IfModule mod_perl.c>

    Perlrequire /opt/otrs/scripts/apache2-perl-startup.pl

    PerlModule Apache2::Reload
    PerlInitHandler Apache2::Reload
    PerlModule Apache2::RequestRec

</IfModule>

<Directory "/opt/otrs/bin/cgi-bin/">
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all
        ErrorDocument 403 /index.pl
		DirectoryIndex index.pl
</Directory>

<Directory "/opt/otrs/var/httpd/htdocs/">
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

<IfModule mod_headers.c>
    <Directory "/opt/otrs/var/httpd/htdocs/skins/*/*/css-cache">
        <FilesMatch "\.(css|CSS)$">
            Header set Cache-Control "max-age=2592000 must-revalidate"
        </FilesMatch>
    </Directory>

    <Directory "/opt/otrs/var/httpd/htdocs/js/js-cache">
        <FilesMatch "\.(js|JS)$">
            Header set Cache-Control "max-age=2592000 must-revalidate"
        </FilesMatch>
    </Directory>
</IfModule>
A few more thoughts:

As I said, it may be possible to run under an OTRS user by changing the username for the subdomain.

It may be possible to move out of /opt/otrs and back into your user folder (I would ideally like mine in /home/username - out of public_html but associated with the user). Doing this requires modifying all references to /opt/otrs and setting them accordingly. Particularly settings in /opt/otrs/Kernel/Config.pm, /opt/otrs/Kernel/Config/Defaults.pm but I'm sure there may be more.

Update: I posted the above prior to setting up the database I attempted to use the installer.pl script to get up and running. To setup the database I used my cpanel user account as the "root" user for mysql and created a mysql user for ORS (username_otrs) in cpanel. While this would create a user, OTRS could not grant access to my user (and it didn't detect if it already had access before the script ran). What I found, however, was by getting this far it populated all the database information for me. I completed the install by modifying the Default.pm and Config.pm files by hand at this point and then logging in with root@localhost/root.

And finally, I was able to move out of /opt/otrs. To do this, I had to do a search and replace across the entire /opt/otrs directory to modify /opt/otrs to /home/username/otrs. If you cd to your OTRS directory, this command can do the replace:

Code: Select all

find ./ -type f | xargs sed -i 's/\/opt\/otrs/\/home\/username\/otrs/'
You of course have to update the vhost include and documentroot mentioned previously to match the new directory as well.
stewartadam
Znuny newbie
Posts: 1
Joined: 03 Jul 2013, 20:43
Znuny Version: Version 3.2
Real Name: Stewart Adam

Re: Install OTRS With Cpanel

Post by stewartadam »

This worked nearly perfectly for me on CentOS 11.38 / CentOS 6, thank you.

One particular item that caused trouble for me was that HasCGI on the account was disabled, and it seems you can't enable this for a single subdomain (even if manually editing the configs in /var/cpanel/userdata). For security reasons I did not want to enable CGI on the whole account, just on the particular subdomain. When CGI is disabled, you'll see that cPanel automatically adds to each VirtualHost:

Code: Select all

Options -ExecCGI -Includes
	RemoveHandler cgi-script .cgi .pl .plx .ppl .perl
This broke the main page (sub.domain.com), but using sub.domain.com/index.pl worked correctly. To work around this, I reconfigured the perl-script handler in the VirtualHost include file:

Code: Select all

AddHandler perl-script .cgi .pl .plx .ppl .perl
I also made a few changes for version 3.2. In the end, the following was used as my config:

Code: Select all

# --
# added for OTRS (http://otrs.org/)
# --

#ScriptAlias /otrs/ "/opt/otrs/bin/cgi-bin/"
Alias /otrs-web/ "/opt/otrs/var/httpd/htdocs/"

<IfModule mod_perl.c>
    # Setup environment and preload modules
    Perlrequire /opt/otrs/scripts/apache2-perl-startup.pl

    # Reload Perl modules when changed on disk
    PerlModule Apache2::Reload
    PerlInitHandler Apache2::Reload

    # mod_perl2 options for GenericInterface
    <Location /nph-genericinterface.pl>
        PerlOptions -ParseHeaders
    </Location>
</IfModule>

<Directory "/opt/otrs/bin/cgi-bin/">
    AddHandler perl-script .cgi .pl .plx .ppl .perl
    PerlResponseHandler ModPerl::Registry
    PerlOptions +ParseHeaders
    PerlOptions +SetupEnv
    DirectoryIndex index.pl
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all

    #ErrorDocument 403 /customer.pl
    ErrorDocument 403 /index.pl

    <IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/html text/javascript text/css text/xml application/json text/json
    </IfModule>
</Directory>

<Directory "/opt/otrs/var/httpd/htdocs/">
    AllowOverride None
    Order allow,deny
    Allow from all

    <IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/html text/javascript text/css text/xml application/json text/json
    </IfModule>
</Directory>

<IfModule mod_headers.c>
    <Directory "/opt/otrs/var/httpd/htdocs/skins/*/*/css-cache">
        <FilesMatch "\.(css|CSS)$">
            Header set Cache-Control "max-age=2592000 must-revalidate"
        </FilesMatch>
    </Directory>

    <Directory "/opt/otrs/var/httpd/htdocs/js/js-cache">
        <FilesMatch "\.(js|JS)$">
            Header set Cache-Control "max-age=2592000 must-revalidate"
        </FilesMatch>
    </Directory>
</IfModule>
arasub
Znuny newbie
Posts: 11
Joined: 14 Aug 2013, 07:33
Znuny Version: 3.2.9
Real Name: arasu

Re: Install OTRS With Cpanel

Post by arasub »

Hi thanks for the post,

this have helped me a lot. i got struck at the last step.

now i get the error "File does not exist: /opt/otrs/bin/cgi-bin/otrs-web, "

this clearly say that issue in redirecting the request to the /opt/otrs/var/httpd/htdocs

if you could help me on this, i would complete the installation.

thanks
arasu.b
ilapko
Znuny newbie
Posts: 2
Joined: 13 Oct 2013, 15:21
Znuny Version: 3.2.11
Real Name: Igor

Re: Install OTRS With Cpanel

Post by ilapko »

Hi,

It is really very uiseful how to, however a few steps are missing:

(1) chmod -R 755 /opt/otrs/bin/cgi-bin/
(2) You need to login to installer database as root not as your cpanel account name. You have to enable mysql root password in WHM - it is disabled by default. In this case all database propagated and database user is connected without errors

More information could be found here: http://wiki.ab5w.com/doku.php?id=otrs
ilapko
Znuny newbie
Posts: 2
Joined: 13 Oct 2013, 15:21
Znuny Version: 3.2.11
Real Name: Igor

Re: Install OTRS With Cpanel

Post by ilapko »

Hi,

It is really very uiseful how to, however a few steps are missing:

(1) chmod -R 755 /opt/otrs/bin/cgi-bin/
(2) You need to login to installer database as root not as your cpanel account name. You have to enable mysql root password in WHM - it is disabled by default. In this case all database propagated and database user is connected without errors

More information could be found here: http://wiki.ab5w.com/doku.php?id=otrs
Post Reply