Learn How To Install osTicket on CentOS 7

December 2, 2019

Table of Contents

If you are using a different system, please check our other tutorials.

osTicket is an open-source customer support ticketing system. osTicket source code is publicly hosted on Github. In this tutorial, you will learn how to install and configure osTicket on CentOS 7.

Requirements

  • HTTP server running Nginx or Apache. This guide will use Nginx.
  • PHP version 5.6 to 7.2, 7.2 is recommended
  • mysqli, gd, gettext, imap, json, mbstring, and xml extension for PHP
  • MySQL database version 5.0 or greater or MariaDB equivalent

Before you begin

Check the CentOS version.

cat /etc/centos-release
# CentOS Linux release 7.6.1810 (Core)

Create a new non-root user account with sudo access and switch to it.

useradd -c "John Doe" johndoe && passwd johndoe
usermod -aG wheel johndoe
su - johndoe

NOTE: Replace johndoe with your username.

Set up the timezone.

timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'

Ensure that your system is up to date.

sudo yum update

Install the needed packages.

sudo yum install -y socat git wget unzip vim

Disable SELinux and Firewall.

sudo setenforce 0 ; sudo systemctl stop firewalld ; sudo systemctl disable firewalld

Install PHP

Setup the Webtatic YUM repo.

sudo yum install epel-release
sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Install PHP, as well as the necessary PHP extensions.

sudo yum install -y php72w php72w-cli php72w-fpm php72w-common php72w-mbstring php72w-curl php72w-gd php72w-mysql php72w-json php72w-xml php72w-imap php72w-intl php72w-pecl-apcu php72w-opcache

Check the version.

php -v
# PHP 7.2.21 (cli) (built: Aug  4 2019 08:42:27) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Check installed PHP extensions.

php -m
# mbstring
# curl
# gd
# PDO
# mysqli
# openssl
# . . .

Start and enable PHP-FPM.

sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.service

Install MariaDB

Install the MariaDB database repo.

sudo vim /etc/yum.repos.d/MariaDB.repo

Copy/paste this to the /etc/yum.repos.d/MariaDB.repo file.

[mariadb]
name = MariaDB
baseurl = https://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Install the MariaDB database server.

sudo yum install -y MariaDB-server MariaDB-client

Check the version.

mysql --version
# mysql  Ver 15.1 Distrib 10.2.26-MariaDB, for Linux (x86_64) using readline 5.1

Start and enable MariaDB.

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Run mysql_secure installation script to improve MariaDB security and set the password for MariaDB root user.

sudo mysql_secure_installation

Connect to MariaDB shell as the root user.

sudo mysql -u root -p
# Enter password

Create an empty MariaDB database and user for osTicket, and remember the credentials.

CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit

NOTE: Replace dbname and username with appropriate names for your setup. Replace password with a strong password.

Install Nginx

Install Nginx.

sudo yum install -y nginx

Check the version.

nginx -v
# nginx version: nginx/1.12.2

Start and enable Nginx.

sudo systemctl start nginx.service
sudo systemctl enable nginx.service

Configure Nginx for use with the osTicket.

sudo vim /etc/nginx/conf.d/osticket.conf

Copy/paste this to the /etc/nginx/conf.d/osticket.conf file.

server {
  listen 80;
  server_name example.com;
  root /var/www/osticket/upload;
  index index.php index.html;
  set $path_info "";
  location ~ /include {
    deny all;
    return 403;
  }
  if ($request_uri ~ "^/api(/[^?]+)") {
    set $path_info $1;
  }
  location ~ ^/api/(?:tickets|tasks).*$ {
    try_files $uri $uri/ /api/http.php?$query_string;
  }
  if ($request_uri ~ "^/scp/.*.php(/[^?]+)") {
    set $path_info $1;
  }
  if ($request_uri ~ "^/.*.php(/[^?]+)") {
    set $path_info $1;
  }
  location ~ ^/scp/ajax.php/.*$ {
    try_files $uri $uri/ /scp/ajax.php?$query_string;
  }
  location ~ ^/ajax.php/.*$ {
    try_files $uri $uri/ /ajax.php?$query_string;
  }
  location / {
    try_files $uri $uri/ index.php;
  }
  location ~ .php$ {
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    fastcgi_param PATH_INFO $path_info;
    fastcgi_pass 127.0.0.1:9000;
  }
}

Save the file and exit with :+W+Q.

Test the configuration.

sudo nginx -t

Reload Nginx.

sudo service nginx restart

Install osTicket

Create a document root directory.

sudo mkdir -p /var/www/osticket

Change ownership of the /var/www/osticket directory to johndoe.

sudo chown -R johndoe:johndoe /var/www/osticket

Navigate to the document root folder.

cd /var/www/osticket

Download and unzip the latest release of osTicket.

wget https://github.com/osTicket/osTicket/releases/download/v1.14.1/osTicket-v1.14.1.zip
unzip osTicket-v1.14.1.zip
rm osTicket-v1.14.1.zip

Copy the sample config file.

sudo cp upload/include/ost-sampleconfig.php upload/include/ost-config.php

Change ownership of the /var/www/osticket directory to nginx.

sudo chown -R nginx:nginx /var/www/osticket

Run sudo vim /etc/php-fpm.d/www.conf and set the user and group to nginx. Initially, they will be set to apache.

sudo vim /etc/php-fpm.d/www.conf
# user = nginx
# group = nginx

Create /var/lib/php/session/ directory and change ownership to nginx.

sudo mkdir -p /var/lib/php/session && sudo chown -R nginx:nginx /var/lib/php/session

Restart the PHP-FPM service.

sudo systemctl restart php-fpm.service

Once everything is configured, it’s time to access the osTicket web installation wizard. Open your site in a web browser and follow the instructions on the screen to finish the installation.

After installation, delete the setup directory for security.

sudo rm -rf upload/setup
sudo chmod 0644 upload/include/ost-config.php

Need help?

Do you need help setting up this on your own service?
Please contact us and we’ll provide you the best possible quote!