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.

Prerequisites

  • 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.

#/bin/bash
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*
%ZMGWSI   %ZMGWSIS  
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

GTM>ZSHOW
CHILD3+5^%ZMGWSIS    (Direct mode) 
XINETD+2^%ZMGWSIS

GTM>H

Then make a bash script to call it:

sam@sam-desktop:~/pocn-moh$ cat mgwsi-rpcproc 
#!/bin/bash
cd /home/sam/pocn-moh
source ./run_utf8
date>>rpc_log.log
$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 

GTM>zshow
CHILD3+5^%ZMGWSIS    (Direct mode) 
XINETD+2^%ZMGWSIS

GTM>h

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
	PER_SOURCE = -1
	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...
Trying 127.0.0.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
    </Location>

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 127.0.1.1 for ServerName
 ... waiting .apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 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
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/completed.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/demologin.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/details.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/ewdAjaxError.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/ewdAjaxErrorRedirect.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/ewdErrorRedirect.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/index.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/newUser.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/selectApp.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/selectLocations.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/selectUser.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/tab1.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/tab2.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/tab3.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/tab4.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDExample/userList.ewd
mkdir: cannot create directory `/iWDApps': Permission denied
mkdir: cannot create directory `/iWDApps/iWDMgr': No such file or directory
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/about.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/[[application~|Application]]s.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/[[configuration~|Configuration]].ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/ewdAjaxError.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/ewdAjaxErrorRedirect.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/ewdErrorRedirect.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/incomplete.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/index.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/login.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/mainMenu.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/pageMenu.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/pages.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/sessionContent.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/sessionDetails.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iWDMgr/sessions.ewd
mkdir: cannot create directory `/iWDApps': Permission denied
mkdir: cannot create directory `/iWDApps/imdb': No such file or directory
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/attributeMenu.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/deleteAttribute.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/deleteDomain.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/deleteItem.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/domainMenu.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/editAttribute.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/ewdAjaxError.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/ewdAjaxErrorRedirect.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/ewdErrorRedirect.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/index.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/itemMenu.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/login.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/newAttribute.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/newDomain.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/newItem.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/notInitialised.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/saveAttribute.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/saveAttributeValue.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/saveDomain.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/imdb/saveItem.ewd
mkdir: cannot create directory `/iWDApps': Permission denied
mkdir: cannot create directory `/iWDApps/iwdmdb': No such file or directory
/home/sam/pocn-moh/ewdapps/iWDApps/iwdmdb/CDMenu.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iwdmdb/CDXArtist.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iwdmdb/CDXArtistList.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iwdmdb/CDXTitle.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iwdmdb/about.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iwdmdb/ewdAjaxError.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iwdmdb/ewdAjaxErrorRedirect.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iwdmdb/ewdErrorRedirect.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iwdmdb/index.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iwdmdb/mainMenu.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/iwdmdb/selectTrack.ewd
mkdir: cannot create directory `/iWDApps': Permission denied
mkdir: cannot create directory `/iWDApps/mdb': No such file or directory
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/addUser.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/addUserResponse.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/applianceAbout.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/displayDomain.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/ewdAjaxError.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/ewdAjaxErrorRedirect.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/ewdDocs.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/ewdErrorRedirect.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/getDomains.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/index.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/initialise.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/initialiseInfo.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/login.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/loginForm.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/mainmenu.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/mdbMenu.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/mdbWelcome.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/mgwsiMgr.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/security.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/showUserInfo.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/showUsers.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/timezone.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/timezoneResponse.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/userDetails.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/vaConfig.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/vaConfigApache.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/vaConfigArchitecture.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/vaConfigExit.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/vaConfigGTM.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/vaConfigIP.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/vaConfigKB.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/vaConfigLinuxGTM.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/vaConfigMGWSI.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/vaConfigMenu.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/vaConfigUsernames.ewd
/home/sam/pocn-moh/ewdapps/iWDApps/mdb/viewer.ewd
  • 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
	</Location>

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>
	<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
	</Location>

</VirtualHost>

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
  </Proxy>

  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.