Thursday, November 23, 2017

Bitnami Redmine Installation on Ubuntu 16.04

Bitnami Redmine Installation on Ubuntu 16.04

Using Bitnami Redmine, go to https://bitnami.com/stack/redmine to download the latest version of Redmine local installer for Linux.
Upload the binary to the server then run it as root
chmod +x bitnami-redmine-<version>-linux-x64-installer.run

./bitnami-redmine-<version>-linux-x64-installer.run

Made a symlink for easy access

ln -s /opt/redmine<version> /opt/redmine

Start/Stop Service

The native installer also includes a command-line script to start, stop and restart applications, named ctlscript.sh. This script can be found in the installation directory and accepts the options startstoprestart, and status. To use it, log in to the server console and execute it following the examples below:
  • Call it without any service names to start all services:
    Note: Only use sudo if the stack was installed as root
    sudo installdir/ctlscript.sh start
    
  • Use it to restart a specific service only by passing the service name as argument - for example, mysql or apache:
    Note: Only use sudo if the stack was installed as root
    sudo installdir/ctlscript.sh restart mysql
    sudo installdir/ctlscript.sh restart apache
    
  • Obtain current status of all services:
    installdir/ctlscript.sh status
    
The list of available services varies depending on the required components for each application.

Email Fetching from Gmail

Install rake to provide /usr/bin/rake
sudo apt-get install rake
Crontab
*/2 5-22 * * * /opt/redmine/helpdeskEmailPoll.sh > /opt/redmine/helpdeskEmailPoll.log
File: /opt/redmine/helpdeskEmailPoll.sh
#!/bin/bash
source /opt/redmine/scripts/setenv.sh
cd /opt/redmine/apps/redmine/htdocs

RAILS_ENV="production" /usr/bin/rake redmine:email:receive_imap host=imap.gmail.com port=993 ssl=1 username=helpdesk@ssis.edu.vn password=h3lpdesk\! project=helpdesk unknown_user=create no_permission_check=1 no_account_notice=1
To check when the last time the cronjob to check the helpdesk email, go to /opt/redmine/helpdeskEmailPoll.log

Use a MySQL trigger to "fix" the Active Directory user auto-creation

A bit of a hack, but it gets the job done. Run this using the "/opt/redmine/mysql/bin/mysql -uroot -p" command line client:
delimiter //
CREATE TRIGGER `user_before_insert` BEFORE INSERT
ON `users`
FOR EACH ROW BEGIN
IF NEW.login like '%@ssis.edu.vn' THEN
SET NEW.login = replace(NEW.login,'@ssis.edu.vn','');
SET NEW.auth_source_id= (SELECT id from auth_sources where type="AuthSourceLdap" and name like "SSIS%" limit 1);
END IF;
END//

CREATE TRIGGER `user_before_update` BEFORE UPDATE
ON `users`
FOR EACH ROW BEGIN
IF NEW.login like '%@ssis.edu.vn' THEN
SET NEW.login = replace(NEW.login,'@ssis.edu.vn','');
SET NEW.auth_source_id= (SELECT id from auth_sources where type="AuthSourceLdap" and name like "SSIS%" limit 1);
END IF;
END//

CREATE TRIGGER `user_after_insert` AFTER INSERT
ON `users`
FOR EACH ROW BEGIN
IF NEW.auth_source_id='1' THEN
SET @groupid := (SELECT DISTINCT id from users where type="Group" and lastname="SSIS Users");
INSERT INTO groups_users (group_id, user_id) VALUES (@groupid, NEW.id);
END IF;
END//

delimiter ;

Accessing PhpMyAdmin On Linux And Mac OS X

To access the application using your Web browser, create an SSH tunnel, as described below.
  • Open a new terminal window on your local system (for example, using "Finder -> Applications -> Utilities -> Terminal" in Mac OS X or the Dash in Ubuntu).
  • You have two options to configure the SSH tunnel: connect to the server using a private key (recommended) or connect to the server using a SSH password. Follow the instructions below per each option:
    • Option 1: Connect to the server using a private key
      • Make sure that you have your SSH credentials (.pem key file) in hand.
      • Run the following command to configure the SSH tunnel. Remember to replace KEYFILE with the path to your private key and SERVER-IP with the public IP address or hostname of your server:
        ssh -N -L 8888:127.0.0.1:80 -i KEYFILE syad@srvr-uredmine.ssis.edu.vn
        
    • Option 2: Connect to the server using a SSH password
      • Run the following command, remembering to replace SERVER-IP with the public IP address or hostname of your server. Enter your SSH password when prompted.
        ssh -N -L 443:127.0.0.1:443 sysad@srvr-uredmine.ssis.edu.vn
        
NOTE: If successful, the above commands will create an SSH tunnel but will not display any output on the server console.
  • Access the phpMyAdmin console through the secure SSH tunnel you created, by browsing to https://127.0.0.1/phpmyadmin.
  • Log in to phpMyAdmin by using the following credentials:
    • Username: root
    • Password: application password

File Attachments

Every year, Redmine will create a new directory under /opt/redmine/apps/redmine/htdocs/files/<year> with the permission ownership of root.root.  We need to change it to daemon.daemon in order for our users to upload new files.  We need to keep in mind to perform this every year or write a cronjob to perform this task.

Tuesday, November 14, 2017

Redirect multiple domain with NGINX

Web server

(web.example.com):  /etc/nginx/sites-available/redirect
server {
listen 80;
server_name records.example.com summer.example.com helpdesk.example.com;
if ($host = 'records.example.com'){
return 301 http://docs.google.com/;
}
if ($host = 'summer.example.com'){
return 301 http://domainsomewhere.net;
}
if ($host = 'helpdesk.example.com'){
return 301 http://youtube.com/sdfasa;
}
}


ln -s /etc/nginx/sites-available/redirect /etc/nginx/sites-enabled/redirect
nginx -t
service nginx restart

DNS

DNS entry point to webserver (ie. records alias to web.example.com)

Thursday, November 2, 2017

Check website page load and trace route

Here are two very nice website page load check and trace route.  It also provide recommendations on how to improve the page's performance.

http://www.monitis.com/pageload/
https://tools.pingdom.com