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. :)

Tags: , , ,

Leave a Reply