如何在Ubuntu 16.04上安裝OTRS(開源問(wèn)題單系統(tǒng))
OTRS ,即開源問(wèn)題單(ticket)申請(qǐng)系統(tǒng),是一個(gè)用于客戶服務(wù)、幫助臺(tái)和 IT 服務(wù)管理的開源問(wèn)題單軟件。該軟件是用 Perl 和 javascript 編寫的。對(duì)于那些需要管理票據(jù)、投訴、支持請(qǐng)求或其他類型的報(bào)告的公司和組織來(lái)說(shuō),這是一個(gè)問(wèn)題單解決方案。OTRS 支持包括 MySQL、PostgreSQL、Oracle 和 SQL Server 在內(nèi)的多個(gè)數(shù)據(jù)庫(kù)系統(tǒng),它是一個(gè)可以安裝在 Windows 和 Linux 上的多平臺(tái)軟件。
在本教程中,我將介紹如何在 Ubuntu 16.04 上安裝和配置 OTRS。我將使用 PostgreSQL 作為 OTRS 的數(shù)據(jù)庫(kù),將 Apache Web 服務(wù)器用作 Web 服務(wù)器。
先決條件
- Ubuntu 16.04。
- 最小 2GB 的內(nèi)存。
- root 權(quán)限
步驟 1 - 安裝 Apache 和 PostgreSQL
在***步中,我們將安裝 Apache Web 服務(wù)器以及 PostgreSQL。我們將從 ubuntu 倉(cāng)庫(kù)中使用***的版本。
使用 SSH 登錄到你的 Ubuntu 服務(wù)器中:
- ssh root@192.168.33.14
更新 Ubuntu 倉(cāng)庫(kù)。
- sudo apt-get update
使用 apt 安裝 Apache2 以及 PostgreSQL:
- sudo apt-get install -y apache2 libapache2-mod-perl2 postgresql
通過(guò)檢查服務(wù)器端口確保 Apache 以及 PostgreSQL 運(yùn)行了。
- netstat -plntu
Install Apache and PostgreSQL
你可以看到 80 端口被 apache 使用了,5432 端口被 postgresql 數(shù)據(jù)庫(kù)使用了。
步驟 2 - 安裝 Perl 模塊
OTRS 基于 Perl,因此我們需要安裝一些 OTRS 需要的 Perl 模塊。
使用這個(gè) apt 命令安裝 perl 模塊:
- sudo apt-get install -y libapache2-mod-perl2 libdbd-pg-perl libnet-dns-perl libnet-ldap-perl libio-socket-ssl-perl libpdf-api2-perl libsoap-lite-perl libgd-text-perl libgd-graph-perl libapache-dbi-perl libarchive-zip-perl libcrypt-eksblowfish-perl libcrypt-ssleay-perl libencode-hanextra-perl libjson-xs-perl libmail-imapclient-perl libtemplate-perl libtemplate-perl libtext-csv-xs-perl libxml-libxml-perl libxml-libxslt-perl libpdf-api2-simple-perl libyaml-libyaml-perl
安裝完成后,我們需要為 apache 激活 Perl 模塊,接著重啟 apache 服務(wù)。
- a2enmod perl
- systemctl restart apache2
接下來(lái),使用下面的命令檢查模塊是否已經(jīng)加載了:
- apachectl -M | sort
Enable Apache Perl Module
你可以在 “Loaded Modules” 部分下看到 perl_module。
步驟 3 - 為 OTRS 創(chuàng)建新用戶
OTRS 是一個(gè)基于 web 的程序并且運(yùn)行與 apache web 服務(wù)器下。為了安全,我們需要以普通用戶運(yùn)行它,而不是 root 用戶。
使用 useradd 命令創(chuàng)建一個(gè) otrs 新用戶:
- useradd -r -d /opt/otrs -c 'OTRS User' otrs
- -r:將用戶作為系統(tǒng)用戶。
- -d /opt/otrs:在 /opt/otrs 下放置新用戶的主目錄。
- -c:備注。
接下來(lái),將 otrs 用戶加入到 www-data 用戶組,因?yàn)?apache 運(yùn)行于 www-data 用戶及用戶組。
- usermod -a -G www-data otrs
在 /etc/passwd 文件中已經(jīng)有 otrs 用戶了。
- grep -rin otrs /etc/passwd
Create new user for OTRS
OTRS 的新用戶已經(jīng)創(chuàng)建了。
步驟 4 - 創(chuàng)建和配置數(shù)據(jù)庫(kù)
在這節(jié)中,我們會(huì)為 OTRS 系統(tǒng)創(chuàng)建一個(gè)新 PostgreSQL 數(shù)據(jù)庫(kù),并對(duì) PostgreSQL 數(shù)據(jù)庫(kù)的配置做一些小的更改。
登錄到 postgres 用戶并訪問(wèn) PostgreSQL shell。
- su - postgres
- psql
創(chuàng)建一個(gè)新的角色 otrs,密碼是 myotrspw,并且是非特權(quán)用戶。
- create user otrs password 'myotrspw' nosuperuser;
接著使用 otrs 用戶權(quán)限創(chuàng)建一個(gè)新的 otrs 數(shù)據(jù)庫(kù):
- create database otrs owner otrs;
- \q
接下來(lái)為 otrs 角色驗(yàn)證編輯 PostgreSQL 配置文件。
- vim /etc/postgresql/9.5/main/pg_hba.conf
在 84 行后粘貼下面的配置:
- local otrs otrs password
- host otrs otrs 127.0.0.1/32 password
保存文件并退出 vim
Database Authentication OTRS
使用 exit 回到 root 權(quán)限并重啟 PostgreSQL:
- exit
- systemctl restart postgresql
PostgreSQL 已經(jīng)為 OTRS 的安裝準(zhǔn)備好了。
Configure PostgreSQL for OTRS
步驟 5 - 下載和配置 OTRS
在本教程中,我們會(huì)使用 OTRS 網(wǎng)站中***的版本。
進(jìn)入 /opt 目錄并使用 wget 命令下載 OTRS 5.0:
- cd /opt/
- wget http://ftp.otrs.org/pub/otrs/otrs-5.0.16.tar.gz
展開該 otrs 文件,重命名目錄并更改所有 otrs 的文件和目錄的所屬人為 otrs。
- tar -xzvf otrs-5.0.16.tar.gz
- mv otrs-5.0.16 otrs
- chown -R otrs:otrs otrs
接下來(lái),我們需要檢查系統(tǒng)并確??梢园惭b OTRS 了。
使用下面的 otrs 腳本命令檢查 OTRS 安裝需要的系統(tǒng)軟件包:
- /opt/otrs/bin/otrs.CheckModules.pl
確保所有的結(jié)果是對(duì)的,這意味著我們的服務(wù)器可以安裝 OTRS 了。
OTRS Chek Module needed for Installation
OTRS 已下載,并且我們的服務(wù)器可以安裝 OTRS 了。
接下,進(jìn)入 otrs 目錄并復(fù)制配置文件。
- cd /opt/otrs/
- cp Kernel/Config.pm.dist Kernel/Config.pm
使用 vim 編輯 Config.pm 文件:
- vim Kernel/Config.pm
更改 42 行的數(shù)據(jù)庫(kù)密碼:
- $Self->{DatabasePw} = 'myotrspw';
注釋 45 行的 MySQL 數(shù)據(jù)庫(kù)支持:
- # $Self->{DatabaseDSN} = "DBI:mysql:database=$Self->{Database};host=$Self->{DatabaseHost};";
取消注釋 49 行的 PostgreSQL 數(shù)據(jù)庫(kù)支持:
- $Self->{DatabaseDSN} = "DBI:Pg:dbname=$Self->{Database};";
保存文件并退出 vim。
接著編輯 apache 啟動(dòng)文件來(lái)啟用 PostgreSQL 支持。
- vim scripts/apache2-perl-startup.pl
取消注釋 60 和 61 行:
- # enable this if you use postgresql
- use DBD::Pg ();
- use Kernel::System::DB::postgresql;
保存文件并退出編輯器。
***,檢查缺失的依賴和模塊。
- perl -cw /opt/otrs/bin/cgi-bin/index.pl
- perl -cw /opt/otrs/bin/cgi-bin/customer.pl
- perl -cw /opt/otrs/bin/otrs.Console.pl
你可以在下面的截圖中看到結(jié)果是 “OK”:
Check all modules again
步驟 6 - 導(dǎo)入樣本數(shù)據(jù)庫(kù)
在本教程中,我們會(huì)使用樣本數(shù)據(jù)庫(kù),這可以在腳本目錄中找到。因此我們只需要將所有的樣本數(shù)據(jù)庫(kù)以及表結(jié)構(gòu)導(dǎo)入到第 4 步創(chuàng)建的數(shù)據(jù)庫(kù)中。
登錄到 postgres 用戶并進(jìn)入 otrs 目錄中。
- su - postgres
- cd /opt/otrs/
作為 otrs 用戶使用 psql 命令插入數(shù)據(jù)庫(kù)以及表結(jié)構(gòu)。
- psql -U otrs -W -f scripts/database/otrs-schema.postgresql.sql otrs
- psql -U otrs -W -f scripts/database/otrs-initial_insert.postgresql.sql otrs
- psql -U otrs -W -f scripts/database/otrs-schema-post.postgresql.sql otrs
在需要的時(shí)候輸入數(shù)據(jù)庫(kù)密碼 myotrspw。
Import OTRS Sample Database
步驟 7 - 啟動(dòng) OTRS
數(shù)據(jù)庫(kù)以及 OTRS 已經(jīng)配置了,現(xiàn)在我們可以啟動(dòng) OTRS。
將 otrs 的文件及目錄權(quán)限設(shè)置為 www-data 用戶和用戶組。
- /opt/otrs/bin/otrs.SetPermissions.pl --otrs-user=www-data --web-group=www-data
通過(guò)創(chuàng)建一個(gè)新的鏈接文件到 apache 虛擬主機(jī)目錄中啟用 otrs apache 配置。
- ln -s /opt/otrs/scripts/apache2-httpd.include.conf /etc/apache2/sites-available/otrs.conf
啟用 otrs 虛擬主機(jī)并重啟 apache。
- a2ensite otrs
- systemctl restart apache2
確保 apache 啟動(dòng)沒(méi)有錯(cuò)誤。
Enable OTRS Apache Virtual Host
步驟 8 - 配置 OTRS 計(jì)劃任務(wù)
OTRS 已經(jīng)安裝并運(yùn)行在 Apache Web 服務(wù)器中了,但是我們?nèi)匀恍枰渲?OTRS 計(jì)劃任務(wù)。
登錄到 otrs 用戶,接著以 otrs 用戶進(jìn)入 var/cron 目錄。
- su - otrs
- cd var/cron/
- pwd
使用下面的命令復(fù)制所有 .dist 計(jì)劃任務(wù)腳本:
- for foo in *.dist; do cp $foo `basename $foo .dist`; done
使用 exit 回到 root 權(quán)限,并使用 otrs 用戶啟動(dòng)計(jì)劃任務(wù)腳本。
- exit
- /opt/otrs/bin/Cron.sh start otrs
Enable OTRS Cron
接下來(lái),手動(dòng)收取電子郵件的 PostMaster 創(chuàng)建一個(gè)新的計(jì)劃任務(wù)。我會(huì)配置為每 2 分鐘收取一次郵件。
- su - otrs
- crontab -e
粘貼下面的配置:
- */2 * * * * $HOME/bin/otrs.PostMasterMailbox.pl >> /dev/null
保存并退出。
現(xiàn)在停止 otrs 守護(hù)進(jìn)程并再次啟動(dòng)。
- bin/otrs.Daemon.pl stop
- bin/otrs.Daemon.pl start
Enable OTRS Fetching Email
OTRS 安裝以及配置完成了。
步驟 9 - 測(cè)試 OTRS
打開你的 web 瀏覽器并輸入你的服務(wù)器 IP 地址: http://192.168.33.14/otrs/
使用默認(rèn)的用戶 root@localhost 以及密碼 root 登錄。
Installation Successfully OTRS Home Page
使用默認(rèn)的 root 賬戶你會(huì)看到一個(gè)警告。點(diǎn)擊警告信息來(lái)創(chuàng)建一個(gè)新的 admin root 用戶。
下面是用另外的 admin root 用戶登錄后出現(xiàn)的 admin 頁(yè)面,這里沒(méi)有出現(xiàn)錯(cuò)誤信息。
OTRS Admin Dashboard Without Error Messages
如果你想作為客戶登錄,你可以使用 customer.pl :http://192.168.33.14/otrs/customer.pl
你會(huì)看到客戶登錄界面,輸入客戶的用戶名和密碼。
OTRS Customer Login Page
下面是一個(gè)創(chuàng)建新單據(jù)的客戶頁(yè)面。
Customer Open Ticket
步驟 10 - 疑難排查
如果你仍舊看到 “OTRS Daemon is not running” 的錯(cuò)誤,你可以像這樣調(diào)試 OTRS 守護(hù)進(jìn)程。
- su - otrs
- cd /opt/otrs/
停止 OTRS 守護(hù)進(jìn)程:
- bin/otrs.Daemon.pl stop
使用 --debug 選項(xiàng)啟動(dòng) OTRS 守護(hù)進(jìn)程。
- bin/otrs.Daemon.pl start --debug
參考