×


Install Open Source osTicket on Ubuntu 20.04 - Step by Step guide ?

osTicket is a PHP-based open-source ticketing system for the Linux platform. It can interface with LDAP / Active Directory for central authentication and supports various databases such as MySQL and PostgreSQL. It’s a straightforward and light-weight web application. You can manage, organize, and archive your support requests with OsTicket. It integrates customer support requests received by email, web forms, and phone calls into a simple, easy-to-use, multi-user web-based platform.

Here at Ibmi Media, we shall look into how to install osTicket on Ubuntu 20.04, using MariaDB as a database server and PHP.


Steps to Install Open Source osTicket on Ubuntu 

1. Perform System Update

Start by updating the system with the latest release packages by the given command:

$ sudo apt-get update


2. Install all PHP and extensions

osTicket application needs the php extensions in order to run the application. Here, all the extensions needed are given and installed:

$ sudo apt install -y php-common php-fpm php-pear php-cgi php-net-socket php-bcmath php-gd php-imap php-intl php-apcu php-cli php-mbstring php-curl php-mysql php-json php-xml

You can check the version of php and all the php extensions with the below command:

$ php -v


3. Install Apache server

Apache web server is installed for the official apt repository:

$ sudo apt install apache2

To start and enable the apache server manually here are the commands listed below. (The service is started on boot by default):

$ sudo systemctl start apache2
$ sudo systemctl enable apache2

To check the status of the apache server to check whether it is running or stopped:

$ sudo systemctl status apache2


4. Install MariaDB database and configure

MariaDB database server is needed with a valid username, password, and hostname during the installation process. The user should be given full privileges on the database created.

Here, the command is used to install the MariaDB server:

$ sudo apt install mariadb-server

To secure the MariaDB server here are the following steps to be done:

$ sudo mysql_secure_installation

After entering the password for root some questions are asked before securing the server. We need to apply yes for all the given questions like:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables

Here, the authentication plugin is changed to be able to login as the normal user:

$ sudo mysql -u root
MariaDB [(none)]> UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> QUIT;

The confirmation of the database working with the below command:

$ mysql -u root -p

Here, a database is created for the osTicket application:

MariaDB [(none)]> CREATE DATABASE osTicket_database;

After the completion of the creating database, we need to create a user osTicket_user for connecting the database and grant privileges. Following queries are for creating a user and connecting it to the database with full privileges granted:

MariaDB [(none)]> CREATE USER ‘osTicket_user’@‘localhost’ IDENTIFIED BY ‘password’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON osTicket_database.* TO osTicket_user@localhost IDENTIFIED BY “password”;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> QUIT;


5. Create Directory for osTicket

The directory is created for the osTicket application giving the path where the directory is being created:

$ sudo mkdir -p /var/www/os_ticket

The directory ownership is changed to the Linux user for further modifications easily without any permission issues:

$ sudo chown -R $USER:$USER /var/www/os_ticket

Now, path to the os_ticket directory using the cd command and pull the latest osTicket installation archive from GitHub using wget command:

$ cd /var/www/os_ticket
$ wget https://github.com/osTicket/osTicket/releases/download/v1.15.2/osTicket-v1.15.2.zip

Extract the download file using the unzip command:

$ unzip osTicket-v1.15.2.zip

(Here, the version must be given according to the file you have downloaded.)

After the archive file is extracted you can delete the zip file:

$ rm osTicket-v1.15.2.zip

osTicket has its own sample configuration file by default. We need to copy the file in the same directories and change its names:

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

chown command is used to assign the owner to the apache server user – www-data and chmod command is used for the appropriate permissions required:

$ sudo chown -R www-data:www-data /var/www/os_ticket
$ sudo chmod -R 755 /var/www/os_ticket


6. Create a Virtual Host File

A configuration file should be created under the path /etc/apache2/sites-available directory in order to run osTicket with apache server.

Here, a2dissite command is used to disable the default Apache configuration file.(In our case it is already disabled).

$ sudo a2dissite 000-default.conf

vim command is used to open the configuration file for editing the information:

$ sudo vim /etc/apache2/sites-enabled/os_ticket.conf

All the information is given below with the necessary permissions and directories. The server name and server alias must be replaced with your domain name and public IP address:

<VirtualHost *:80>
ServerName 192.168.120.129 #localhost
 ServerAlias www.osticket.com #Your domain name
 DocumentRoot "/var/www/os_ticket/upload"
<Directory "/var/www/os_ticket/upload">
 Require all granted
 Options Indexes FollowSymLinks
 AllowOverride All
 Order allow, deny
 Allow from all
</Directory>
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

After the configuration file is done and saved, a2ensite command is used to enable the configuration file.(In my case it is already enabled):

$ sudo a2ensite os_ticket.conf

Finally, restart the apache service to reload the new configuration file:

$ sudo systemctl restart apache2

The firewall is enabled by default so, to get access to the site you can either disable the firewall with the command below or can assign the designated port for the site:

$ ufw disable


7. Install Osticket on the system

  • After the installation process is done, open the firefox app and visit the site using the servername.
  • Now, the following page is opened.
  • Click continue to proceed to the next page.
  • Now, enter all the credentials given and complete the form. Here, you should provide all the information as per the requirement.
  • The database created before in the system should be written in the osTicket Basic Installation form.
  • The confirmation page is opened after the form is filled with the right credentials.
  • Next, you will see the dashboard of the admin.


8. Configure HTTPS / SSL Certificate for Osticket

We should enable a secure HTTPS connection on PrestaShop. We can obtain a free TLS certificate from Let’s Encrypt. Install Let's Encrypt client (Certbot) from Ubuntu 20.04 repository:

$ sudo apt install certbot python3-certbot-apache

Next, run the following command to obtain a free TLS certificate using the Apache plugin:

$ sudo certbot --apache --agree-tos --redirect --staple-ocsp --email you@example.com -d example.com

If the test is successful, reload Apache for the change to take effect:

$ sudo apache2ctl -t
$ sudo systemctl reload apache2


How to access osTicket Web Interface ?

osTicket will be available on HTTP port 80 by default. Open your favorite browser and navigate to https://your-domain.com or https://server-ip-address.


[Need to fix Nginx / Apache configuration issue ? We can help you. ]


Conclusion

This article covers how to install the osTicket open source ticket system on Ubuntu 20.04 LTS Focal Fossa system. In fact, OsTicket allows you to manage, organize and archive your support request. It seamlessly routes inquiries created via email, web-forms, and phone calls into a simple, easy-to-use, multi-user, web-based customer support platform.


How to install osTicket with Nginx on Ubuntu ?

1. Update the system

First, log in to your server with sudo privileges and update the system with the latest stable version using the following command:

$ sudo apt update &&  sudo apt upgrade -y


2. Install LEMP Server

OsTicket requires Web server, PHP and Database Server to be installed on your server.

i. Install Nginx Web Server

You can install Nginx web server by the following command:

$ sudo apt install nginx -y

Now let's check Nginx service and To start the service manually, run the following commands:

$ sudo systemctl status nginx
$ sudo systemctl start nginx

Now enable nginx service to start at boot time by running the following command:

$ sudo systemctl enable nginx

ii. Install PHP and PHP-FPM

Next, you need to install PHP, PHP-FPM and some additional PHP modules which are required for OsTicket to run properly:

$ sudo apt install php php-mysql php-cgi php-fpm php-cli php-curl php-gd php-imap php-mbstring php-xml-util php-intl php-apcu php-common php-gettext php-bcmath

Above command will install php-7.2

Now edit php.ini file by running following command in terminal.

$ sudo vim /etc/php/7.2/fpm/php.ini

Uncomment cgi.fix_pathinfo variable and change its value to 0

cgi.fix_pathinfo=0

Now save and close the file.

Next, restart php7.2-fpm service and enable it at startup using the following command:

$ sudo systemctl restart php7.2-fpm
$ sudo systemctl enable php7.2-fpm

iii. Install and Configure MySQL Database server for OsTicket

From your terminal window, issue the following command to install the MySQL database server:

$ sudo apt install mysql-server

Now start MySQL service and enable it to start at boot time then check MySQL service status with the following command:-

$ sudo systemctl start mysql
$ sudo systemctl enable mysql
$ sudo systemctl status mysql

Next, secure MySQL installation with the following command:

$ sudo mysql_secure_installation

Answer all the questions as below:

Set root password? [Y/n] Y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Next, log in to MySQL console as shown below:

$ sudo mysql -u root -p

Enter your Root password here.

Now you need to create the database for osTicket

run following command:

$ mysql> create database osticket_db;
$ mysql> grant all privileges on osticket_db.* to osticket_user identified by 'OsTicketPassw0rd@19';
$ mysql> flush privileges;


3. Download and Configure osTicket

Create a new directory for osTicket and then go to that directory:

$ sudo mkdir -p /var/www/osticket/
$ cd /var/www/osticket/

Next download latest osTicket setup using wget and Extract it using the following command:-

$ sudo apt-get install wget unzip
$ sudo wget https://github.com/osTicket/osTicket/releases/download/v1.14.1/osTicket-v1.14.1.zip
$ sudo unzip osTicket-v1.14.1.zip

You will get scripts and upload directory after extracting.

Next create an osTicket configuration file from ost-sampleconfig.php file using the following command:

$ sudo su -
$ cd upload/
$ cp ost-sampleconfig.php ost-config.php

Next, you need to change ownership of the osTicket web directory to the 'www-data' user and group.

$ sudo chown -R www-data:www-data /var/www/osticket/


4. Create OsTicket Virtual Host

Now create new virtual host configuration for OsTicket by running following command:

$ sudo vim /etc/nginx/sites-available/osticket.conf

Paste the configuration as below:

server {
listen 80;
server_name 13.52.217.10;   ## change server_name as per your domain name.
root /var/www/osticket/upload;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
index index.php index.html index.htm;

# Enable gzip
gzip on;
gzip_min_length 1000;
gzip_types text/plain application/x-javascript text/xml text/css application/xml;
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;
}
location ~ ^/scp/ajax.php/.*$ {
try_files $uri $uri/ /scp/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;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
}

Here, You need to change server_name 13.52.217.10 as per your domain name.

Save the Nginx configuration file and exit.

Now activate the virtual host and test the configuration:

$ ln -s /etc/nginx/sites-available/osticket.conf /etc/nginx/sites-enabled/
$ nginx -t

Now restart nginx service:

$ sudo systemctl restart nginx


5. Install and configure osTicket

Now let's enter your domain name to get osTicket UI in any web browser.

Next Click on 'Continue' and you will be redirected to the osTicket configuration section.

Fill all required information and click “Install Now” button.

In the database settings, enter details as dbname, username, and password you have created during mysql setup.

Finally, Click on Install Now button

Next, change the permission of ost-config.php to remove write access by running the following command:

$ cd /var/www/osticket/upload/
$ chmod 0644 include/ost-config.php

For osTicket admin type your IP/domain name in the web browser.

For admin login/agent panel/Admin panel configuration type as following:

  • osTicket admin login - http://yourdomainname/scp/
  • osTicket agent panel - http://yourdomainname/scp/index.php
  • osTicket Admin panel configuration - http://yourdomainname/scp/settings.php