Tutorial: How to get OpenEMR Running on a Synology DS214+ NAS

cravaus wrote on Saturday, August 02, 2014:

Getting OpenEMR running on a Synology NAS has not been documented and the changes that need to be made to get it running are not easily found. With the help of this forum and Google I have success. I am new to Linux and to server technology. I will share what I have learned:

Port forward Router Settings:
TCP only: 80,443,873,5001
TCP and UDP: 137-139,445,465,995,993,1194

Similar settings are on the NAS firewall except on the NAS 22 needs to be open for Local SSH access.

DynamicDNS is free with Synology and works with the Patient Portal if you have your own domain name.

Use the Web Directory only for your website. Do not install OpenEMR there it will not work.

MariaDB, phpMyAdmin, VPN Server, must be loaded.

SSH services, SSL, HTTPS and FTPS all need to be enabled

You must create one user, enable a personal website location for that user. OpenEMR needs to be extracted and installed in the www folder for that user.

Redirect for SSL Encryption
Edit httpd.conf-user

At the line:
<VirtualHost :80>
Include sites-enabled-user/
.conf
Add the following
Redirect permanent /~[User Name]/openemr https://Your.Domain:443/~[User Name]/openemr

Restart: /usr/syno/sbin/synoservicecfg --restart httpd-user

Edit globals.php
Change this line:
$web_root = substr($webserver_root, strspn($webserver_root ^ $server_document_root, “\0”));
To be:
$web_root = ‘/~[User Name]/openemr’;

Start the installation with www.Your DomainName/~[User Name]/openemr

Modify OpenEMR phpMyAdmin config file
chmod 0755 /volume1/homes/[user]/www/openemr/phpmyadmin/config.inc.php

Patient Portal: The NAS must be bootstrapped
There is no boot strap package for the DS214+. The older Kirkwood mv6281 bootstrap package will work. Instructions here helped me get it installed.
http://forum.synology.com/wiki/index.php/Overview_on_modifying_the_Synology_Server,_bootstrap,_ipkg_etc

You will need to install bash
Use: ipkg install bash

Using OpenVPN
You cannot use the graphic utility in the Synology DSM OS to run the VPN for the Patient Portal.
You must use a command line to start it and modifications are needed.

Path to OpenVPN: /usr/sbin/openvpn

Location for OpenEMR Portal Certificates:
You will need to extract the OpenEMR zip file to: /usr/syno/etc/synovpnclient/openvpn/

Change permissions
chmod 600 pass
chmod 400 ca.crt
chmod 400 www.YourDNS.com.crt
chmod 400 www.YourDNS.com.key

Set up the Tun module library:
cd /lib/modules/
insmod tun.ko

Edit connect.sh
Delete all and change to
#!/opt/bin/bash
cd /usr/syno/etc/synovpnclient/openvpn/
openvpn --config vpnclient.ovpn &
Save

Change permissions on this file:
chmod 0777 /usr/syno/etc/synovpnclient/openvpn/connect.sh

Make it executable:
cd /usr/syno/etc/synovpnclient/openvpn/
chmod +x connect.sh

Edit disconnect.sh
Change
#! /bin/bash
To
#!/opt/bin/bash

Save

Change permissions on this file:
chmod 0777 /usr/syno/etc/synovpnclient/openvpn/disconnect.sh

Make it executable:
cd /usr/syno/etc/synovpnclient/openvpn/
chmod +x connect.sh

Add the following to rc.local for automatic vpn connectivity when it restarts:
cd /etc/rc.local
Open to edit, add the following path to the end before Exit 0:
/usr/syno/etc/synovpnclient/openvpn/connect.sh

Run the following to start VPN for OpenEMR:
./connect.sh
This should start the program and you will see a string of commands. It will take a minute or two to complete and it will end with a statement such as: “This completes the installation sequence.”

And it works!

mdsupport wrote on Sunday, August 03, 2014:

If it works with tiny ARM processors, it may be worth a shot to see if it can run on a rooted Android 64GB phone or tablet with this $2.54 investment!

bradymiller wrote on Thursday, August 07, 2014:

Hi Craig,

I recommend placing this tutorial on the wiki:
http://www.open-emr.org/wiki/index.php/OpenEMR_Installation_Guides

Feel free to request a wiki account here (I’ll gladly approve the request):
http://www.open-emr.org/wiki/index.php/Special:RequestAccount

-brady
OpenEMR

cravaus wrote on Wednesday, July 01, 2015:

I have noticed that each time the DSM OS updates the Apache Configuration file updates with it and looses the edits for OpenEMR. So you will need to return to the /etc/httpd/conf/httpd.conf-user file and add the following to the end of the file after <VirtualHost *:80>

For example:

<VirtualHost :80>
Include sites-enabled-user/
.conf
Redirect permanent /~[User]/openemr https://www..:443/~[User]/openemr

include conf/extra/mod_xsendfile.conf-user
Include conf/extra/httpd-reqtimeout.conf
Include conf/extra/httpd-proxy-autoconf.conf-user

<Directory “/volume1/homes/[User]/www/openemr”>
AllowOverride FileInfo

<Directory “/volume1/homes/[User]/www/openemr/sites”>
AllowOverride None

<Directory “/volume1/homes/[User]/www/openemr/sites//documents">
order deny,allow
Deny from all

<Directory "/volume1/homes/[User]/www/openemr/sites/
/edi”>
order deny,allow
Deny from all

<Directory “/volume1/homes/[User]/www/openemr/sites/*/era”>
order deny,allow
Deny from all

Restart apache in the terminal, e.g. PuTTY
/usr/syno/sbin/synoservicecfg --restart httpd-user