# Linux下如何安裝OTRS
## 目錄
1. [OTRS簡介](#otrs簡介)
2. [系統要求](#系統要求)
3. [安裝前準備](#安裝前準備)
4. [安裝步驟詳解](#安裝步驟詳解)
- 4.1 [安裝依賴環境](#安裝依賴環境)
- 4.2 [數據庫配置](#數據庫配置)
- 4.3 [下載OTRS](#下載otrs)
- 4.4 [安裝OTRS](#安裝otrs核心)
- 4.5 [Web服務器配置](#web服務器配置)
5. [初始化配置](#初始化配置)
6. [常見問題解決](#常見問題解決)
7. [安全加固建議](#安全加固建議)
8. [維護與升級](#維護與升級)
<a id="otrs簡介"></a>
## 1. OTRS簡介
OTRS(Open-source Ticket Request System)是一款開源的服務臺和IT服務管理(ITSM)解決方案,現更名為Znuny。它提供:
- 工單跟蹤系統
- 知識庫管理
- 服務級別協議(SLA)監控
- 多語言支持(含中文)
- 豐富的插件生態系統
典型應用場景包括客戶服務、IT幫助臺和內部流程管理等。
<a id="系統要求"></a>
## 2. 系統要求
### 硬件要求
| 組件 | 最低配置 | 推薦配置 |
|------------|----------|----------|
| CPU | 2核 | 4核+ |
| 內存 | 4GB | 8GB+ |
| 存儲 | 20GB | 50GB+ |
### 軟件環境
- **操作系統**:CentOS 7+/Ubuntu 18.04+
- **數據庫**:MySQL 5.7+/MariaDB 10.3+
- **Web服務器**:Apache 2.4+/Nginx 1.18+
- **Perl版本**:5.16+
<a id="安裝前準備"></a>
## 3. 安裝前準備
### 3.1 系統更新
```bash
# CentOS/RHEL
sudo yum update -y && sudo yum upgrade -y
# Ubuntu/Debian
sudo apt update && sudo apt upgrade -y
sudo useradd -r -d /opt/otrs -c 'OTRS User' otrs
# 開放HTTP/HTTPS
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
sudo yum install -y epel-release
sudo yum install -y mariadb-server mariadb httpd mod_perl \
perl-core perl-Crypt-Eksblowfish perl-Encode-HanExtra \
perl-GD perl-GDGraph perl-JSON-XS perl-Mail-IMAPClient \
perl-PDF-API2 perl-Text-CSV_XS perl-XML-Parser perl-YAML-LibYAML
sudo apt install -y apache2 libapache2-mod-perl2 mariadb-server \
libdbd-mysql-perl libtimedate-perl libnet-dns-perl \
libnet-ldap-perl libio-socket-ssl-perl libpdf-api2-perl \
libgd-graph-perl libtext-csv-xs-perl libjson-xs-perl \
libxml-parser-perl libcrypt-eksblowfish-perl libyaml-libyaml-perl
sudo systemctl enable --now mariadb
sudo mysql_secure_installation
CREATE DATABASE otrs CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'otrs'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON otrs.* TO 'otrs'@'localhost';
FLUSH PRIVILEGES;
wget https://ftp.otrs.org/pub/otrs/otrs-6.0.30.tar.gz
tar xzf otrs-6.0.30.tar.gz -C /opt
sudo mv /opt/otrs-6.0.30 /opt/otrs
sudo chown -R otrs:apache /opt/otrs
cd /opt/otrs
sudo -u otrs bin/otrs.CheckModules.pl
sudo -u otrs cp Kernel/Config.pm.dist Kernel/Config.pm
sudo -u otrs bin/otrs.Console.pl Maint::Database::Check
sudo -u otrs bin/otrs.Console.pl Maint::Database::Create
<VirtualHost *:80>
ServerName otrs.example.com
DocumentRoot /opt/otrs/var/httpd/htdocs/
<Directory /opt/otrs/var/httpd/htdocs/>
Options +ExecCGI -Includes
AllowOverride None
Require all granted
</Directory>
Perlrequire /opt/otrs/scripts/apache2-perl-startup.pl
PerlModule ModPerl::Registry
PerlOptions +Parent
<Location /otrs>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
</Location>
</VirtualHost>
server {
listen 80;
server_name otrs.example.com;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location ~ ^/otrs/ {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /opt/otrs/bin/cgi-bin/;
}
}
sudo -u otrs bin/otrs.Daemon.pl start
sudo -u otrs bin/Cron.sh start
http://your-server-ip/otrs/installer.pl
# 使用CPAN安裝缺失模塊
sudo perl -MCPAN -e 'install Crypt::Eksblowfish::Bcrypt'
檢查/opt/otrs/Kernel/Config.pm
中的配置:
$Self->{'DatabaseHost'} = 'localhost';
$Self->{'Database'} = 'otrs';
$Self->{'DatabaseUser'} = 'otrs';
$Self->{'DatabasePw'} = 'StrongPassword123!';
測試郵件配置:
sudo -u otrs bin/otrs.Console.pl Admin::Config::Update \
--setting-name 'SendmailModule' \
--value 'Kernel::System::Email::SMTP'
sudo chmod -R 750 /opt/otrs
sudo chown -R otrs:apache /opt/otrs
sudo certbot --apache -d otrs.example.com
# 數據庫備份
mysqldump -u otrs -p otrs > otrs_backup_$(date +%F).sql
# 文件備份
tar czf /backup/otrs_files_$(date +%F).tar.gz /opt/otrs
# 檢查系統狀態
sudo -u otrs bin/otrs.Console.pl Maint::Config::Sync
# 重建索引
sudo -u otrs bin/otrs.Console.pl Maint::Cache::Delete
sudo -u otrs bin/otrs.Console.pl Admin::Package::UpgradeAll
提示:本文基于OTRS 6.0編寫,具體操作時請參考官方文檔獲取最新指南。建議生產環境部署前在測試環境充分驗證。 “`
注:實際字數為約4500字,如需擴展到6100字,可考慮以下擴展方向: 1. 增加各步驟的詳細原理說明 2. 添加更多屏幕截圖示例 3. 擴展故障排查案例庫 4. 增加性能調優章節 5. 詳細對比不同Linux發行版的安裝差異 6. 添加與第三方系統集成方案
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。