EWD Install Instructions

From VistApedia
Jump to: navigation, search

Welcome to my page on installing EWD. I am doing this on Ubuntu. If you do this on a Red Hat like system, you have to adapt the instructions.



  • Latest Version of GT.M installed
  • VISTA installed

Install Git and download the Git Repo of EWD

I make my own directory called src or svn or whatever and put all the source code in it.

sudo apt-get install git-core				; Get Git
git clone git://github.com/robtweed/EWD.git		; Get EWD

EWD Installation Using Apache

This will install EWD using Apache as the web facing gateway to EWD. To install it using Node, see below.

Install and Set-up mgwsi

MGWSI is the tcp listener on GT.M that listens for apache requests. Make a routine directory that will be part of the $gtmroutines add add that directory to your $gtmroutines. (Or you could just use a directory already in the existing gtmroutines.) Here's my GT.M env set-up script, for example. I am running in UTF-8 mode, so you will see extra lines that have to do with that.

cd ~/pocn-moh
export gtm_dist=/opt/fis-gtm/V5.4-002A/utf8/
export gtmroutines="uo(routines svn/BMX ewdroutines) $gtm_dist"
export gtmgbldir=mumps.gld
export PATH=$PATH:$gtm_dist
export gtm_chset=utf-8
export gtm_icu_version=4.2

Copy the ZMGWSI routines from EWD's m_apache directory to your routines folder.

cp svn/EWD/m_apache/*.m ewdroutines/

Verify that the routines are found by GT.M:

sam@sam-desktop:~/pocn-moh$ mumps -dir

GTM>d ^%RD

Routine directory
Routine: %ZM*
Total of 2 routines.

Run the program now to make sure it compiles properly.

sam@sam-desktop:~/pocn-moh$ mumps -r INETD^%ZMGWSIS
%GTM-I-CTRLC, CTRL_C encountered

CHILD3+5^%ZMGWSIS    (Direct mode) 


Then make a bash script to call it:

sam@sam-desktop:~/pocn-moh$ cat mgwsi-rpcproc 
cd /home/sam/pocn-moh
source ./run_utf8
$gtm_dist/mumps -run INETD^%ZMGWSIS 2>> rpc_log.log
exit 0

# Make it executable
sam@sam-desktop:~/pocn-moh$ chmod +x mgwsi-rpcproc 

# Run it
sam@sam-desktop:~/pocn-moh$ ./mgwsi-rpcproc 

CHILD3+5^%ZMGWSIS    (Direct mode) 


Now we put it as a xinetd service

# Create the following line in [[configuration~|Configuration]] file: /etc/services
mgwsi           7041/tcp                # Service for MGWSI clients

# Create Xined script that calls mgwsi-rpcproc
sudo cat mgwsi_pocn-moh_7041
service mgwsi-pocn-moh-7041
        disable	= no
        port = 7041
        socket_type = stream
        protocol = tcp
        user = sam
        server = /bin/bash
        groups = yes
        server_args = /home/sam/pocn-moh/mgwsi-rpcproc
        type = UNLISTED
        wait = no

Now we test it by putting xinetd in debug mode and then telneting to the port.

sam@sam-desktop:/etc/xinetd.d$ sudo xinetd -d &
[2] 10521
Service [[configuration~|Configuration]]: mgwsi-pocn-moh-7041
	id = mgwsi-pocn-moh-7041
	flags = IPv4
	type = UNLISTED
	socket_type = stream
	Protocol (name,number) = (tcp,6)
	port = 7041
	wait = no
	user = 1000
	Groups = yes
	Bind = All addresses.
	Server = /bin/bash
	Server argv = bash /home/sam/pocn-moh/mgwsi-rpcproc
	Only from: All sites
	No access: No blocked sites
	No logging
11/5/23@10:41:33: DEBUG: 10521 {cnf_start_services} Started service: mgwsi-pocn-moh-7041
11/5/23@10:41:33: NOTICE: 10521 {main} xinetd Version 2.3.14 started with libwrap loadavg options compiled in.
11/5/23@10:41:33: NOTICE: 10521 {main} Started working: 8 available services
11/5/23@10:41:33: DEBUG: 10521 {main_loop} active_services = 8
telnet localhost 7041
Trying ::1...
11/5/23@10:41:52: DEBUG: 10521 {main_loop} select returned 1
Connected to localhost.
Escape character is '^]'.
11/5/23@10:41:52: DEBUG: 10521 {server_start} Starting service mgwsi-pocn-moh-7041
11/5/23@10:41:52: DEBUG: 10521 {main_loop} active_services = 8
11/5/23@10:41:52: DEBUG: 10523 {exec_server} duping 14

telnet> quit
Connection closed.
sam@sam-desktop:/etc/xinetd.d$ 11/5/23@10:41:57: DEBUG: 10521 {main_loop} active_services = 8
11/5/23@10:41:57: DEBUG: 10521 {main_loop} select returned 1
11/5/23@10:41:57: DEBUG: 10521 {check_pipe} Got signal 17 (Child exited)
11/5/23@10:41:57: DEBUG: 10521 {child_exit} waitpid returned = 10523
11/5/23@10:41:57: DEBUG: 10521 {server_end} mgwsi-pocn-moh-7041 server 10523 exited
11/5/23@10:41:57: INFO: 10521 {conn_free} freeing connection
11/5/23@10:41:57: DEBUG: 10521 {child_exit} waitpid returned = -1
11/5/23@10:41:57: DEBUG: 10521 {main_loop} active_services = 8

Once you are sure it works, foreground your xinetd process and kill it using Ctrl-C.

Setting up m_apache

First, make sure that m_apache is the right architecture for your machine. If not, you need to compile the m_apache.c file. The compilation instructions are from the source. Also, Mike Clayton's 64 bit installers for EWD provide the m_apache22 file in 64 bit format which you can extract from the .deb file.

sam@sam-desktop:~/pocn-moh/svn/EWD/m_apache$ file m_apache22.so 
m_apache22.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped

Copy to the lib folder of apache modules: in Ubuntu: /usr/lib/apache2/modules

sudo cp m_apache22.so /usr/lib/apache2/modules/

Configure your apache so that it will route all pages in a specific location to Mumps. Make sure to get your gld file correctly. I edited my /etc/apache2/sites-available/default to have these lines:

    LoadModule m_apache_module /usr/lib/apache2/modules/m_apache22.so
    <Location /ewd>
        SetEnv MGWSI_PORT 7041
        SetEnv MGWSI_M_UCI /home/sam/pocn-moh/mumps.gld
        SetEnv MGWSI_M_FUNCTION runPage^%zewdGTMRuntime

Restart apache and make sure there aren't any errors.

sam@sam-desktop:/etc/apache2/sites-available$ sudo service apache2 restart
 * Restarting web server apache2                                                                                                          apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
 ... waiting .apache2: Could not reliably determine the server's fully qualified domain name, using for ServerName
                                                                                                                                   [ OK ]

Test M apache. In a web browser, navigate to http://localhost/ewd/index.mgwsi. You should get an EWD Error Page. If you get an apache error message, something is wrong.

SELinux and Apache to MGWSI

If you do get an apache Service Unavailable message, it could be due to SELinux.

Review /var/log/audit/audit.log. See if there is a AVC type message like this:

type=AVC msg=audit(1317316775.606:57870): avc:  denied  { name_connect } for  pid=15027 comm="httpd" dest=7041 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:port_t:s0 tclass=tcp_socket

If you see something like this, you need to tell SELinux the following:

semanage port -a -t http_port_t -p tcp 7041

Install EWD M Files

Copy the EWD Mumps files to a GT.M Mumps directory. They are all in the root of the repo.

sam@sam-desktop:~/pocn-moh/svn$ cp EWD/*.m ../ewdroutines/

Install Resources

You need to install a bunch of files under /var/www:
# Copy iwd from the root directory to /var/www/
sudo cp -r iwd /var/www/

# Copy the resources files from the ewdMgr/resourceFiles directory to /var/www/resources (which you need to make)
sudo mkdir -p /var/www/resources
sudo chmod 777 /var/www/resources/
sudo cp ewdMgr/resourceFiles/* /var/www/resources

# Get the YUI library and install it.
wget http://yui.zenfs.com/releases/yui2/yui_2.6.0r2.zip
sudo unzip yui_2.6.0r2.zip -d /var/www/
sudo chmod 777 /var/www/yui/

Install EWD Applications

# Make a directory for [[application~|Application]]s
sam@sam-desktop:~/pocn-moh$ mkdir ewdapps

# Copy the ewdMgr and iwd to that directory
cp -r ewdMgr/ ../../ewdapps/
cp -r iWDApps/ ../../ewdapps/

Configure EWD for the First Run

There are many bugs in this area, so make sure to read below so you know what you are in for before doing any of these steps.

GTM>KILL ^zewd

GTM>D compileAll^%zewdAPI("ewdMgr")

Installing/Configuring Enterprise Web Developer (Build 790)

Note: hit Esc to go back at any point

[[Application~|Application]] Root Path (/usr/ewdapps): /home/sam/pocn-moh/ewdapps
Routine Path (/usr/local/gtm/ewd/): /home/sam/pocn-moh/ewdroutines/
Javascript and CSS File Output Path (/var/www/resources/): /var/www/resources/
Javascript and CSS File URL Path (/resources/): /resources/

Enterprise Web Developer (Build 790) is configured and ready for use

EWD First Run Bugs

  • _zewdDocumentation2.m contains invalid Unicode characters. I cleaned it up using iconv.
iconv -fUTF8 -tUTF8 -c _zewdDocumentation2.m -o _zewdDocumentation2.m
  • EWD expects to be able to write to /var/www/resources. I put that in the instructions for that section.
  • For some reason, EWD switches the routine path the first time it connects from the web. Why??? So you have to fix it manually. AND REMEMBER TO PUT A TRAILING SLASH. THAT ONE CAUGHT ME FOR A WHILE!!!
S ^zewd("config","routinePath","gtm")="/home/sam/pocn-moh/ewdroutines/"
  • Issue of compiling Applications with subdirectories. Where is it supposed to output? Update: Rob says ignore for now. Here's an example:
GTM>d compileAll^%zewdAPI("iWDApps")
mkdir: cannot create directory `/iWDApps': Permission denied
mkdir: cannot create directory `/iWDApps/iWDExample': No such file or directory
mkdir: cannot create directory `/iWDApps': Permission denied
mkdir: cannot create directory `/iWDApps/iWDMgr': No such file or directory
mkdir: cannot create directory `/iWDApps': Permission denied
mkdir: cannot create directory `/iWDApps/imdb': No such file or directory
mkdir: cannot create directory `/iWDApps': Permission denied
mkdir: cannot create directory `/iWDApps/iwdmdb': No such file or directory
mkdir: cannot create directory `/iWDApps': Permission denied
mkdir: cannot create directory `/iWDApps/mdb': No such file or directory
  • I wasn't able to get YUI tags to work. The JS to load them properly in the webpage is there, but is not evaluated. I will work on that later.

Setting Up the Special MGWSI Functions Location

You need this for several cryptographic functions to work:

	<Location "/mgwsi/sys/">
	# This is a reserved location used for the m_apache systems facilities invoked through: 
	# /mgwsi/sys/system_functions.mgwsi
	Order deny,allow
	Allow from all

Setting Up SSL With EWD

There is nothing to it. Follow the instructions here: http://wiki.centos.org/HowTos/Https then make your config file as follows (Note that I did this on CentOS):

LoadModule m_apache_module modules/m_apache22.so
ServerName example.com

NameVirtualHost *:443
<VirtualHost *:443>
        SSLEngine on
        SSLCertificateFile /etc/pki/tls/certs/ca.crt
        SSLCertificateKeyFile /etc/pki/tls/private/ca.key
        <Location /ewd>
                SetEnv MGWSI_PORT 7041
                SetEnv MGWSI_M_UCI /opt/worldvista/EHR/globals/mumps.gld
                SetEnv MGWSI_M_FUNCTION runPage^%zewdGTMRuntime
	<Location "/mgwsi/sys/">
	# This is a reserved location used for the m_apache systems facilities invoked through: 
	# /mgwsi/sys/system_functions.mgwsi
	Order deny,allow
	Allow from all


RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Setting up the SSL Proxy for EWD

There is a special case where you are trying to access external ssl connections from within EWD using the http methods in %zewdGTM. If you do so, you will need to configure a proxy on port 89 that forwards your connections from EWD to the ssl port. This is done using Apache's mod_proxy and mod_ssl. My thanks to David W and Larry L for the instructions on how to set this up and prevent it from being abused.

These instructions are for Debian systems.

First, enable the modules ssl and proxy.

sudo a2enmod proxy
sudo a2enmod proxy_connect
sudo a2enmod proxy_ftp
sudo a2enmod proxy_http
sudo a2enmod ssl

Set-up this config file for apache:

  Listen 89
  SSLProxyEngine on
  ProxyRequests on

  <Proxy *>
    Order deny,allow
    Deny from all
    Allow from localhost

  SSLProxyEngine on
  SSLProxyVerify none

  ProxyVia on

Miscellaneous Stuff

Compiling m_apache

I am troubleshooting a bug in m_apache right now: I needed to re-compile it because I think I may have an older version. If the bug shows up again, well, I can change the source. I did this on CentOS 6; your luck may differ.

You need m_apache.c from the EWD repo, which you downloaded in step 1.

yum install gcc
yum install httpd-devel
yum install openssl-devel
apxs -i -a -I/usr/include/openssl/ -n m_apache22 -o m_apache22.so -c m_apache.c

I also figured out how to do it with plain gcc using the tips apxs gave me.

> gcc -fPIC -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing  -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/include/httpd  -I/usr/include/apr-1   -I/usr/include/apr-1  -I/usr/include/openssl/  -c -o m_apache.obj m_apache.c
> gcc -shared -rdynamic -o m_apache22.so m_apache.obj

EWD Installation using Node.js

The instructions here are no longer accurate and do not reflect EWD.js. For installation instructions, go to http://gradvs1.mgateway.com/download/EWDjs.pdf.

Personal tools