Skip to content

OTRS China 1.0.12

otrs-china-1.0.12.tar.gz 此安装包互联网上我没有找到,我在以前amd64的镜像里拿到了一个,otrs-china-1.0.12.tar.gz

安装环境: centos 7.9.2009

测试时间:20250805

注意事项:默认的yum源已经不可用了,需要换源,注意ARM/AMD的yum源配置不一样

安装

解压安装包

注意:这里的目录固定为 “ /opt/otrs ” 貌似很多配置都是这个路径,此提示仅供参考

bash
$ tar -zxf otrs-china-1.0.12.tar.gz
$ mv otrs-china-1.0.12new/ /opt/otrs

创建用户

bash
$ useradd -d /opt/otrs/ -c 'OTRS user' otrs

安装依赖

bash
$ yum -y install epel-release perl cpan
$ cd /opt/otrs/bin/
$ perl /opt/otrs/bin/otrs.CheckModules.pl
$ yum install -y "perl(Archive::Tar)" "perl(Archive::Zip)" "perl(Crypt::Eksblowfish::Bcrypt)" "perl(Crypt::Eksblowfish::Bcrypt)" "perl(Crypt::SSLeay)" "perl(Date::Format)" "perl(DBI)" "perl(Encode::HanExtra)" "perl(IO::Socket::SSL)" "perl(JSON::XS)" "perl(Mail::IMAPClient)" "perl(IO::Socket::SSL)" "perl(Authen::SASL)" "perl(Authen::NTLM)" "perl(ModPerl::Util)" "perl(Net::DNS)" "perl(Net::LDAP)" "perl(Template)" "perl(Template::Stash::XS)" "perl(Text::CSV_XS)" "perl(Time::Piece)" "perl(XML::LibXML)" "perl(XML::LibXSLT)" "perl(XML::Parser)" "perl(YAML::XS)" "perl(DBD::mysql)" "perl(DBD::Pg)"
$ perl /opt/otrs/bin/otrs.CheckModules.pl

复制配置文件

bash
$ cp /opt/otrs/Kernel/Config.pm.dist /opt/otrs/Kernel/Config.pm
$ cp /opt/otrs/var/cron/otrs_daemon.dist /opt/otrs/var/cron/otrs_daemon
$ chmod 775 /opt/otrs/var/cron/otrs_daemon
$ chmod +x /opt/otrs/bin/otrs.SetPermissions.pl

检查配置文件

bash
$ perl -cw /opt/otrs/bin/cgi-bin/index.pl
$ perl -cw /opt/otrs/bin/cgi-bin/customer.pl
$ perl -cw /opt/otrs/bin/otrs.PostMaster.pl

文件授权

bash
$ perl /opt/otrs/bin/otrs.SetPermissions.pl --web-group=apache --otrs-user=otrs

修改httpd配置文件

bash
# 将 /etc/httpd/conf/httpd.conf 配置文件中的 User 值改成 otrs
$ vi /etc/httpd/conf/httpd.conf
User apache
# 改为
User otrs

启动

bash
$ /usr/sbin/httpd -DFOREGROUND

镜像构建

默认的yum源已经不可用了,需要换源,注意ARM/AMD的yum源配置文件不一样,但是Dockerfile是一样的

Dockerfile

dockerfile
FROM centos:7.9.2009

LABEL name="otrs-china" \
	 vendor="otrs-china" \
	 maintainer="Liulike" \
	 version="1.0.12" \
	 release="1.0.12" \
	 BASE_IMAGE="centos:7.9.2009" \
	 summary="基于 centos:7.9.2009 镜像叠加的 otrs-china-1.0.12" \
      description="初始化页面: http://<ip>:<port>/otrs/installer.pl, 初始化后挂载对应的配置文件即可" \
      run="docker run -d --name NAME -p 80:80 IMAGE" \
      stop="docker stop NAME"

ADD otrs-china-1.0.12.tar.gz /opt/
COPY CentOS-Base.repo /etc/yum.repos.d/

ENV TZ=Asia/Shanghai

RUN set -e \
    && mv /opt/otrs-china-1.0.12new/ /opt/otrs \
    && useradd -d /opt/otrs/ -c 'OTRS user' otrs \
    && cd /opt/otrs/bin/ \
    && yum clean all && yum makecache && yum repolist \
    && yum install -y epel-release \
    && yum -y install cronie httpd httpd-devel mod_perl perl-core procmail \
    && yum install -y "perl(Archive::Tar)" "perl(Archive::Zip)" "perl(Crypt::Eksblowfish::Bcrypt)" "perl(Crypt::Eksblowfish::Bcrypt)" "perl(Crypt::SSLeay)" "perl(Date::Format)" "perl(DBI)" "perl(Encode::HanExtra)" "perl(IO::Socket::SSL)" "perl(JSON::XS)" "perl(Mail::IMAPClient)" "perl(IO::Socket::SSL)" "perl(Authen::SASL)" "perl(Authen::NTLM)" "perl(ModPerl::Util)" "perl(Net::DNS)" "perl(Net::LDAP)" "perl(Template)" "perl(Template::Stash::XS)" "perl(Text::CSV_XS)" "perl(Time::Piece)" "perl(XML::LibXML)" "perl(XML::LibXSLT)" "perl(XML::Parser)" "perl(YAML::XS)" "perl(DBD::mysql)" "perl(DBD::Pg)" \
    && yum clean all && yum clean metadata && yum clean headers \
    && perl /opt/otrs/bin/otrs.CheckModules.pl \
    && cp /opt/otrs/Kernel/Config.pm.dist /opt/otrs/Kernel/Config.pm \
    && cp /opt/otrs/var/cron/otrs_daemon.dist /opt/otrs/var/cron/otrs_daemon \
    && chmod 775 /opt/otrs/var/cron/otrs_daemon \
    && chmod +x /opt/otrs/bin/otrs.SetPermissions.pl \
    && perl -cw /opt/otrs/bin/cgi-bin/index.pl \
    && perl -cw /opt/otrs/bin/cgi-bin/customer.pl \
    && perl -cw /opt/otrs/bin/otrs.PostMaster.pl \
    && perl /opt/otrs/bin/otrs.SetPermissions.pl --web-group=apache --otrs-user=otrs 

COPY httpd.conf /etc/httpd/conf/

EXPOSE 80

CMD ["/usr/sbin/httpd", "-DFOREGROUND"]

CentOS-Base.repo

AMD64

shell
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

ARM64

shell
[base]
name=CentOS-7.9.2009 - Base - Aliyun
baseurl=https://mirrors.aliyun.com/centos-vault/altarch/7.9.2009/os/aarch64/
enabled=1
gpgcheck=0
 
[updates]
name=CentOS-7.9.2009 - Updates - Aliyun
baseurl=https://mirrors.aliyun.com/centos-vault/altarch/7.9.2009/updates/aarch64/
enabled=1
gpgcheck=0
 
[extras]
name=CentOS-7.9.2009 - Extras - Aliyun
baseurl=https://mirrors.aliyun.com/centos-vault/altarch/7.9.2009/extras/aarch64/
enabled=1
gpgcheck=0

httpd.conf

去掉了注释内容,实际只需要修改用户信息: User otrs

shell
ServerRoot "/etc/httpd"

Listen 80

Include conf.modules.d/*.conf
Include /opt/otrs/scripts/apache2-httpd.include.conf
User otrs 
Group apache


ServerAdmin root@localhost


<Directory />
    AllowOverride none
    Require all denied
</Directory>


DocumentRoot "/var/www/html"

<Directory "/var/www">
    AllowOverride None
    Require all granted
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks

    AllowOverride None

    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>


    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>


    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig /etc/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz



    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>


EnableSendfile on

IncludeOptional conf.d/*.conf

构建

bash
$ docker build -t liulike/otrs-china:1.0.12 .

部署

Docker

bash
$ docker run -itd \
  --name otrs-china \
  -p 80:80 \
  liulike/otrs-china:1.0.12

访问页面: http://<ip>:<port>/otrs/installer.pl 进行初始化系统

初始化后页面会显示用户和密码

初始化后将 /opt/otrs/Kernel/Config.pm 挂载出来即可

bash
$ docker run -itd \
  --name otrs-china \
  -v $(pwd)/Config.pm:/opt/otrs/Kernel/Config.pm \
  -p 80:80 \
  liulike/otrs-china:1.0.12

K8S

yaml
---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: otrs
  namespace: otrs
  labels:
    app: otrs
spec:
  replicas: 1
  selector:
    matchLabels:
      app: otrs
  template:
    metadata:
      labels:
        app: otrs
    spec:
      volumes:
        - name: otrs-conf
          configMap:
            name: otrs
            items:
              - key: Config.pm
                path: Config.pm
            defaultMode: 420
      containers:
        - name: otrs
          image: 'liulike/otrs-china:1.0.12'
          ports:
            - containerPort: 80
              protocol: TCP
          resources: {}
          volumeMounts:
            - name: otrs-conf
              mountPath: /opt/otrs/Kernel/Config.pm
              subPath: Config.pm
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      securityContext: {}
      schedulerName: default-scheduler

---
kind: Service
apiVersion: v1
metadata:
  name: otrs
  namespace: otrs
  labels:
    app: otrs
spec:
  ports:
    - name: web
      protocol: TCP
      port: 80
      targetPort: 80
  selector:
    app: otrs
  type: ClusterIP

---
kind: ConfigMap
apiVersion: v1
metadata:
  name: otrs
  namespace: otrs
data:
  Config.pm: |
    package Kernel::Config;
    use strict;
    use warnings;
    use utf8;
    sub Load {
        my $Self = shift;
        $Self->{'DatabaseHost'} = 'xxx.xxx.xxx.xxx:3306';
        $Self->{'Database'} = "otrs";
        $Self->{'DatabaseUser'} = "otrs";
        $Self->{'DatabasePw'} = 'otrs#123@2025!';
        $Self->{'DatabaseDSN'} = "DBI:mysql:database=$Self->{Database};host=$Self->{DatabaseHost}";
        $Self->{Home} = '/opt/otrs';
    }
    use Kernel::Config::Defaults; # import Translatable()
    use base qw(Kernel::Config::Defaults);
    1;

登录页面

http://<ip>:<port>/otrs/index.pl

更改密码

bash
$ su otrs
$ cd /opt/otrs/bin
$ ./otrs.Console.pl Admin::User::SetPassword root@localhost 123456

Logo更改

bash
$ cd /opt/otrs/var/httpd/htdocs/skins/Agent/default/img/