tech and other rants

orangehrm with nginx on top

November 11th, 2014 in tech, Uncategorized

I know it’s been a a very long while, but I have to rant somewhere about the lack of documentation on software.

I tried installing orangehrm today, and, of course their website has no documentation on how to install and get it working on an nginx webserver.

After searching online and being frustrated that no one had the right answer I started investigating further and got it working with the below config.

This config, redirects http requests to https, so that all traffic is done on SSL

Be sure to change the following:

server_name your.domain.name;
root /opt/orangehrm/symfony/web/;
listen your.ip.addre.ss:443 ssl;
access_log  /var/log/nginx/your.domain.name/access.log;
error_log  /var/log/nginx/your.domain.name/error.log;
ssl_certificate      /etc/nginx/ssl/domain.name.crt;
ssl_certificate_key  /etc/nginx/ssl/domain.name.key;
fastcgi_pass unix:/var/run/php-fpm.sock;

Add the below config to /etc/nginx/conf.d or /etc/nginx/sites-available

server {
    listen 83.246.0.38:80;
    server_name your.domain.name;
    rewrite        ^ https://$server_name$request_uri? permanent;
}
server {
	server_name your.domain.name;
	root /opt/orangehrm/symfony/web/;
	listen your.ip.addre.ss:443 ssl;
	autoindex off;
	client_max_body_size 15M;
	client_body_buffer_size 128k;
	index index.html index.htm index.php;
	access_log  /var/log/nginx/your.domain.name/access.log;
	error_log  /var/log/nginx/your.domain.name/error.log;
	keepalive_requests    10;
	keepalive_timeout     60 60;
	ssl_certificate      /etc/nginx/ssl/domain.name.crt;
	ssl_certificate_key  /etc/nginx/ssl/domain.name.key;
	location ~ \.php$ {
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		fastcgi_pass unix:/var/run/php-fpm.sock;
		fastcgi_index index.php;
		fastcgi_param PATH_INFO $fastcgi_path_info;
		fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include fastcgi_params;
	}
	location / {
		index index.php;
		try_files $uri /index.php?$args;
	}
        location ~ /\.ht {
                deny all;
        }

        location ~ .*\.log {
                deny all;
        }

        location ~ log.*\.txt {
                deny all;
        }

        location ~ .*.yml {
                deny all;
        }
        # /symfony/web/index.php/auth/login
        location /symfony/web/ {
                rewrite ^/$ /index.php;
                rewrite ^/([^.]+)$ /$1.html;
                if (!-e $request_filename){
                        rewrite ^(.*)$ /index.php break;
                }
        }
}

That’s it for the ranting. :)

OS X: How to hide menu bar and dock when opening an application

October 25th, 2009 in osx, programming

I have an application that i like using it in windowed mode. But since there’s the menu bar up top it doesn’t seem to completly enter the screen. So I had to do something to autohide the bar whenever i use this app.
I found a very easy way to do this.

First open Finder and go to the folder where the app is, right-click on it and press Show Package Contents
Show Package Contents
This will open up a new finder windows displaying a folder called Contents. Enter that folder.
Now you will see a file, Info.plist. Open it with a plist editor like PlistEdit Pro . I like to use TextMate for this.
After opening the file look for NSAppleScriptEnabled:
NSAppleScriptEnabled
Right above that line add the following:

LSUIPresentationMode - No Menubar
Save and close, and now open the application. Voila! No more menubar. If you move your mouse over the top of the screen the menubar will apear as long as you keep your mouse on it.

debian preseed with no swap

October 14th, 2009 in os deploy, programming

I recently had to create an automatic vm install via pxe of debian Lenny 5.0.
I had two hdds, one for / and one for swap. Since partman cannot handle recipes with multiple hdds i had to manualy create swap with a preseed late_command: echo “;” | sfdisk /dev/sdb . Now i faced the problem that the setup was warning me of not having a swap. The next line added to preseed fixed my problem:
# Skip question about not having swap partition
partman-basicfilesystems partman-basicfilesystems/no_swap boolean false

debian/ubuntu swap question

For Ubuntu kickseed the line is similar:


preseed --owner partman-basicfilesystems partman-basicfilesystems/no_swap boolean false

Song of the day – Nicu Alifantis – Rar

May 26th, 2009 in music, video

 

Very nice song from a poem of Bacovia 

 

autodeploy generated nconf nagios config

April 6th, 2009 in Uncategorized

Recently I started playing with this backend interface for Nagios called NConf. This is a very young project but from what I see it’s a very promising project:
http://sourceforge.net/projects/nconf/

Since it’s a new project it lacks some features such as, after generating nagios config files, it does not put them into production. So i created a little script that run in cron and check if new configs were created, if yes it put them into the right place and restarts nagios if there are no errors:

Put this code into a new file. Be sure to modify the paths at the beginning with what corresponds with your setup.
do a chmod +x filename on the file

then run crontab -e
and add a silimar line:
*/5 * * * * /path/to/filename

Now every 5 minutes the script will look for new generated configs and put the into nagios. Then checks if there are errors and if there aren’t it restarts nagios.

Nagios is an opensource monitoring system that support custom checks. More info at nagios.org

New Adio sticker added

April 3rd, 2009 in stickers

I like this one a lot
stickers2

Small backup script

March 9th, 2009 in programming

Saw a clip recently about some company not having backups and lost a lot of data and realized i didn’t have backups either so I decided to make a short bash script that covers everything i need.
small backup script

For ease of use put in some config variables. Edit these lines with the required info:

email_address=”your.address@gmail.com”
db_name=”wp_blog”
backup_dir=”/kit/backup”
domain_name=”tech.mariusb.com”
www_dir=”/var/www/$domain_name”

Create a file called .my.cnf in your home directory with the user & password for the database connection like so:

[client]
user=wp_user
password=your_pass

If you have a small site you could setup so that this script send you an e-mail with the archived backup. You will have to modify the send_backup_on_mail to yes and install on your linux system mutt.
Depending on the linux flavor you’ll have to do yum install mutt or aptitude install mutt or whatever else.

Now that you have the script ready you will have to put it to run every day using cron and make in executable:

chmod +x script_name.sh # make in executable

Create a symlink in the daily cron folder:
ln -sf /dir/of/script/script_name.sh /etc/cron.daily/script_name.sh

And that’s it, you will permanently have 3 site backups, and the old ones will be automaticaly deleted.
If you have questions please post comments.

list enum set from a mysql table field

March 3rd, 2009 in programming
 function enum_select( $table , $field ){
        $query = " SHOW COLUMNS FROM `$table` LIKE '$field' ";
        $result = mysql_query( $query ) or die( 'error getting enum field ' . mysql_error() );
        $row = mysql_fetch_array( $result , MYSQL_NUM );
        $regex = "/'(.*?)'/";
        //$regex = "/'[^"\\\r\n]*(\\.[^"\\\r\n]*)*'/";
        preg_match_all( $regex , $row[1], $enum_array );
        $enum_fields = $enum_array[1];
        //print_r($enum_fields);
        return($enum_fields);
}

If you just want to see the values uncomment the print_r line and execute the function:

enum_select(table1,field1);

Now for example if you want to create a dropdown with this array you do:

echo "";

The result will look something like this:
result

Stickers on my laptop

February 14th, 2009 in stickers

photo1

Looking for more cool ones :)

Ordered some hak5 schwag

Charity Water

February 8th, 2009 in charity

Go to twestival and support all the tweeters out there and the people without clean water.


Jennifer Connelly in charity: water Public Service Announcement from charity: water