{"id":163,"date":"2021-11-05T20:46:41","date_gmt":"2021-11-05T19:46:41","guid":{"rendered":"http:\/\/35.243.187.182\/?p=163"},"modified":"2021-11-05T20:52:34","modified_gmt":"2021-11-05T19:52:34","slug":"osticket-on-ubuntu-with-ssl","status":"publish","type":"post","link":"https:\/\/www.tillnet.se\/index.php\/2021\/11\/05\/osticket-on-ubuntu-with-ssl\/","title":{"rendered":"osTicket on Ubuntu with SSL"},"content":{"rendered":"\n<p>Everyone needs a ticket system, right?<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Disclaimer or Scope\/Intention<\/h2>\n\n\n\n<p>This is how I did it. Short guide, more or less for myself so I won&#8217;t forget.<br>If Linux\/Ubuntu\/Apache\/SSL-certs is new territory for you this isn&#8217;t the guide you were looking for, sorry. Some steps and detailed explanations are omitted.<br>Also never run cmds you don&#8217;t trust and know what they do.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What I used<\/h2>\n\n\n\n<p>Machine: VM in Vmware vSphere, 1vCPU, 2GB RAM, 40GB disk.<br>OS: Ubuntu Server 20.04 LTS Free OpenSource (https:\/\/ubuntu.com\/download\/server)<br>WebApp: osTicket 1.15.4 Free OpenSource (https:\/\/osticket.com\/download\/)<br>SSL cert: I used Let&#8217;s Encrypt for my cert and key.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Preparation<\/h2>\n\n\n\n<p>I downloaded the software from Ubuntu and osTicket. Spun up a small VM and installed Ubuntu Server on it. Performed some housekeeping on the machine.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Install LAMP Stack (Linux, Apache, MySQL, and PHP)<\/h2>\n\n\n\n<p>On the newly setup Ubuntu machine install LAMP Stack and some extra pieces.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install tasksel\nsudo tasksel install lamp-server\nsudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc\nSudo apt install php-imap\nSudo phpenmod imap<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Configure Domain and Apache<\/h2>\n\n\n\n<p>-Setup DNS<br>Go to your web domain registrar and create A record pointing to your new server. Or your DNS-resolver if you only will access the system from your homelab or LAN.<\/p>\n\n\n\n<p>-Configure Apache conf for website<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo cd \/etc\/apache2\/sites-available\nsudo nano example.com.conf<\/code><\/pre>\n\n\n\n<p>Paste into editor:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Directory \/var\/www\/example.com>  \n        Require all granted  \n&lt;\/Directory>  \n&lt;VirtualHost *:80>\n    ServerAdmin webmaster@example.com\n    ServerName example.com\n    ServerAlias www.example.com\n    DocumentRoot \/var\/www\/example.com\n    ErrorLog ${APACHE_LOG_DIR}\/error.log\n    CustomLog ${APACHE_LOG_DIR}\/access.log combined\n&lt;\/VirtualHost><\/code><\/pre>\n\n\n\n<p>Close and save. Ctrl+X, Y, Enter<\/p>\n\n\n\n<p>-Create folder for webpage content, enable the website and restart Apache.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir -p \/var\/www\/example.com\nsudo a2dissite 000-default.conf\nsudo a2ensite example.com.conf\nsudo systemctl reload apache2<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Prep Database<\/h2>\n\n\n\n<p>-Create database and database-user, set secure password.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mysql -u root  \n> CREATE DATABASE osTicket; \n> CREATE USER 'osticketuser' IDENTIFIED BY 'password';\n> GRANT ALL ON osTicket.* TO 'osticketuser';  \n> quit  \nmysql_secure_installation<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Upload osTicket an configure<\/h2>\n\n\n\n<p>UnZip the file you downloaded from osticket.com.<br>Upload the contents of the &#8220;upload&#8221; folder to your website folder on the server &#8220;\/var\/www\/example.com&#8221;.<\/p>\n\n\n\n<p>From a web browser go to http:\/\/example.com\/setup and follow the onscreen instructions. More commands and you&#8217;ll need the database-user credentials.<\/p>\n\n\n\n<p>After setup is complete you can start setting it up as you like.<\/p>\n\n\n\n<p>Tip: If you configure mail-fetcher add line in crontab.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nano \/etc\/crontab<\/code><\/pre>\n\n\n\n<p>Paste into editor:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>*\/5 * * * * www-data \/usr\/bin\/php \/var\/www\/example.com\/api\/cron.php<\/code><\/pre>\n\n\n\n<p>Close and save. Ctrl+X, Y, Enter<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Get SSL cert and key<\/h2>\n\n\n\n<p>All websites should use https now when there&#8217;s free and easy services like Let&#8217;s Encrypt (https:\/\/letsencrypt.org) or Cloudflare (https:\/\/cloudflare.com). There are good guides on their webpages and also a lot of specific howtos to find elsewhere. This is out of scope for this guide.<\/p>\n\n\n\n<p>Get your cert and key from source of your choosing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Copy Cert and Key to Server<\/h2>\n\n\n\n<p>Create a new directory where yout Cert and Key will reside.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo mkdir-p \/etc\/letsencrypt\/<\/code><\/pre>\n\n\n\n<p>Using nano text editor, create a new file example.com.pem (where example.com is your own domain).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano\/etc\/letsencrypt\/example.com.pem<\/code><\/pre>\n\n\n\n<p>Now paste in your Origin Certificate. Save file and exit. (Press CTRL + X, press Y and then press ENTER).<\/p>\n\n\n\n<p>Create a new file example.com.key (where example.com is your own domain).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano\/etc\/letsencrypt\/example.com.key<\/code><\/pre>\n\n\n\n<p>Paste in your Private Key. Save file and exit. (Press CTRL + X, press Y and then press ENTER).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Configure Apache for https<\/h2>\n\n\n\n<p>Firstly, make sure you have the SSL module enabled for Apache by running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo a2enmod ssl<\/code><\/pre>\n\n\n\n<p>Open the Apache configuration file for your domain.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano\/etc\/apache2\/sites-available\/example.com.conf<\/code><\/pre>\n\n\n\n<p>You need to add a new block underneath for SSL port 443. You can also add a rewrite condition in your port 80 block to redirect all requests to https. Paste example and modify for your domain.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Directory \/var\/www\/example.com>  \n        Require all granted  \n&lt;\/Directory>  \n&lt;VirtualHost *:80>\n    ServerAdmin webmaster@example.com\n    ServerName example.com\n    ServerAlias www.example.com\n    DocumentRoot \/var\/www\/example.com\n    ErrorLog ${APACHE_LOG_DIR}\/error.log\n    CustomLog ${APACHE_LOG_DIR}\/access.log combined\n\n    ReWriteEngine on\n    ReWriteCond %{SERVER_NAME} =example.com\n    ReWriteRule ^ https:\/\/%{SERVER_NAME}%{REQUEST_URI} &#91;END,NE,R=permanent]\n\n&lt;\/VirtualHost>\n&lt;VirtualHost *:443>\n\n    ServerAdmin webmaster@example.com\n    ServerName example.com\n    ServerAlias www.example.com\n    DocumentRoot \/var\/www\/example.com\n    ErrorLog ${APACHE_LOG_DIR}\/error.log\n    CustomLog ${APACHE_LOG_DIR}\/access.log combined\n\n    SSLEngine on\n    SSLCertificateFile \/etc\/letsencrypt\/example.com.pem\n    SSLCertificateKeyFile \/etc\/letsencrypt\/example.com.key\n\n&lt;\/VirtualHost><\/code><\/pre>\n\n\n\n<p>Save file and exit. (Press CTRL + X, press Y and then press ENTER).<\/p>\n\n\n\n<p>Enable the RewriteEngine.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo a2enmod rewrite<\/code><\/pre>\n\n\n\n<p>Test the configuration syntax for errors.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apachectl configtest<\/code><\/pre>\n\n\n\n<p>You can ignore any errors that say <em>Could not reliably determine the server\u2019s fully qualified domain name<\/em>.<br>If you see <em>Syntax OK<\/em>, restart Apache.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudosystemctl restart apache2<\/code><\/pre>\n\n\n\n<p>Done. Now you have your own ticket system to handle and keep track of everything your other personality is doing =).<br>Tip: Piss them of by rejecting their Change Requests, just for the fun of it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Everyone needs a ticket system, right? Disclaimer or Scope\/Intention This is how I did it. Short guide, more or less for myself so I won&#8217;t &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-163","post","type-post","status-publish","format-standard","hentry","category-it"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/posts\/163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/comments?post=163"}],"version-history":[{"count":2,"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/posts\/163\/revisions"}],"predecessor-version":[{"id":165,"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/posts\/163\/revisions\/165"}],"wp:attachment":[{"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/media?parent=163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/categories?post=163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tillnet.se\/index.php\/wp-json\/wp\/v2\/tags?post=163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}