<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://daq00.triumf.ca/MidasWiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dfujimoto</id>
	<title>MidasWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://daq00.triumf.ca/MidasWiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dfujimoto"/>
	<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php/Special:Contributions/Dfujimoto"/>
	<updated>2026-04-28T20:38:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MIDAS_experiment_at_TRIUMF&amp;diff=3606</id>
		<title>Setup MIDAS experiment at TRIUMF</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MIDAS_experiment_at_TRIUMF&amp;diff=3606"/>
		<updated>2026-03-12T20:50:34Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setup experiment database (ODB) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This page describes setting up a MIDAS experiment at TRIUMF. This information can be adapted for other sites.&lt;br /&gt;
&lt;br /&gt;
== Environment variables ==&lt;br /&gt;
* &#039;&#039;&#039;MIDASSYS&#039;&#039;&#039; Base directory of the MIDAS package, midas and mxml should be at the same level.&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_EXPTAB&#039;&#039;&#039; Experiment definition file&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_SERVER_HOST&#039;&#039;&#039; MIDAS host server name for remote midas connections.&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_EXPT_NAME&#039;&#039;&#039; Experiment name&lt;br /&gt;
&lt;br /&gt;
== Standard layout of MIDAS experiment ==&lt;br /&gt;
The following shows the directory layout of a standard MIDAS experiment: &lt;br /&gt;
&lt;br /&gt;
 /home/exptuser/&lt;br /&gt;
                packages/&lt;br /&gt;
                        root                   &amp;lt;---- ROOT&lt;br /&gt;
                        mxml&lt;br /&gt;
                        mscb&lt;br /&gt;
                        midas/                 &amp;lt;---- MIDAS&lt;br /&gt;
                              linux/{lib,bin}       &amp;lt;---- binaries matching the selected 64-bit/32-bit flavour of ROOT&lt;br /&gt;
                              linux-m32/{lib,bin}   &amp;lt;---- limited function 32-bit binaries for 32-bit frontend machines, build by &amp;quot;make linux32&amp;quot;&lt;br /&gt;
                              linux-m64/{lib,bin}   &amp;lt;---- limited function 64-bit binaries (only needed if ROOT and linux/bin are 32-bit)&lt;br /&gt;
                              linux-arm/{lib,bin}   &amp;lt;---- full function ARM cross-compiled using &amp;quot;make linuxarm&amp;quot;&lt;br /&gt;
                              linux-crosscompile/{lib,bin}  &amp;lt;---- cross-compiled limited function binaries for PPC and ARM frontends (see Makefile)&lt;br /&gt;
                        rootana                &amp;lt;---- ROOT analyzer&lt;br /&gt;
                        roody                  &amp;lt;---- graphical online histogram viewer for MIDAS and ROOTANA&lt;br /&gt;
                 online/&lt;br /&gt;
                        exptab                         &amp;lt;---- experiment definition&lt;br /&gt;
                        {.ODB,.SYSTEM,.SYSMSG,etc}.SHM &amp;lt;---- MIDAS shared memory save files&lt;br /&gt;
                        src                            &amp;lt;---- experiment frontend sources&lt;br /&gt;
                        bin,scripts&lt;br /&gt;
                        elog                           &amp;lt;---- MIDAS elog&lt;br /&gt;
                        history                        &amp;lt;---- MIDAS history&lt;br /&gt;
                        data -&amp;gt; /data/exptname/current &amp;lt;---- symlink to the data directory&lt;br /&gt;
 /data/exptname/current                                &amp;lt;---- experiment data directory with ODB save files and MIDAS .mid/.mid.gz data files&lt;br /&gt;
&lt;br /&gt;
== Prepare computers ==&lt;br /&gt;
&lt;br /&gt;
On some operating systems, several MIDAS functions require administrator access:&lt;br /&gt;
&lt;br /&gt;
* on el7 linux (SL7/CC7/CentOS7/RHEL7) - access to mhttpd port 8443 requires special firewall rules, see here: https://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
* on el7 linux - access to mserver to run frontends and other programs on some other computer requires special firewall rules, see here: https://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
* on el7 linux - on the frontend machines (and other machines that will connect to the mserver, the same firewall rule needs to be created (use the IP address of the machine running the mserver)&lt;br /&gt;
&lt;br /&gt;
== Prepare the user account ==&lt;br /&gt;
&amp;lt;div id=&amp;quot;NOTES&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Setup the user account for running this instance of midas. For machines part of the LADD cluster, follow these  [http://daq-plone.triumf.ca/SM/docs/local/NewLaddUser] instructions.&lt;br /&gt;
* check that the account is using the /bin/bash shell&lt;br /&gt;
* make $HOME/.profile look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/echo You must source&lt;br /&gt;
&lt;br /&gt;
export SVN_EDITOR=&amp;quot;emacs -nw&amp;quot;&lt;br /&gt;
export GIT_EDITOR=&amp;quot;emacs -nw&amp;quot;&lt;br /&gt;
export MIDASSYS=$HOME/packages/midas&lt;br /&gt;
export ROOTANASYS=$HOME/packages/rootana&lt;br /&gt;
export MIDAS_EXPTAB=$HOME/online/exptab&lt;br /&gt;
#&lt;br /&gt;
# setup the MIDAS mserver&lt;br /&gt;
#&lt;br /&gt;
case `hostname` in&lt;br /&gt;
daq07*)&lt;br /&gt;
   unset MIDAS_SERVER_HOST&lt;br /&gt;
   ;;&lt;br /&gt;
*)&lt;br /&gt;
   export MIDAS_SERVER_HOST=daq07.triumf.ca:7070&lt;br /&gt;
   ;;&lt;br /&gt;
esac&lt;br /&gt;
#&lt;br /&gt;
# select 64-bit or 32-bit MIDAS and ROOT&lt;br /&gt;
#&lt;br /&gt;
case `uname -i` in&lt;br /&gt;
i386)&lt;br /&gt;
   source /daq/daqshare/olchansk/root/root_v5.34.01_SL62_32/bin/thisroot.sh&lt;br /&gt;
   export PATH=.:$MIDASSYS/linux-m32/bin:$PATH&lt;br /&gt;
   ;;&lt;br /&gt;
*)&lt;br /&gt;
   #source /daq/daqshare/olchansk/root/root_v5.34.34_SL67_64/bin/thisroot.sh&lt;br /&gt;
   source $HOME/packages/root/bin/thisroot.sh&lt;br /&gt;
   export PATH=.:$MIDASSYS/linux/bin:$PATH&lt;br /&gt;
   ;;&lt;br /&gt;
esac&lt;br /&gt;
#&lt;br /&gt;
export PATH=.:$HOME/online/bin:$HOME/packages/roody/bin:$PATH&lt;br /&gt;
#&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* mkdir $HOME/packages&lt;br /&gt;
* Logout and login again, for .cshrc changes to take effect&lt;br /&gt;
&lt;br /&gt;
== Install ROOT ==&lt;br /&gt;
&lt;br /&gt;
* Identify the Linux version: RH9 (Red Hat Linux 9), FC3 (Fedora Core 3), RHEL4/SL4 (Red Hat Enterprise LInux 4/Scientific Linux 4), SL5x, SL6x, (CentOS/CC/SL) el7x: more /etc/redhat-release&lt;br /&gt;
* Decide to use 32-bit or 64-bit ROOT (&#039;uname -a&#039;)&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* ls -l /daq/daqshare/olchansk/root/ ### to see all available ROOT packages&lt;br /&gt;
* ln -s /daq/daqshare/olchansk/root/root_vNNN_VVV_BB root, where NNN is the latest available version of ROOT (&amp;quot;ls -l /daq/daqshare/olchansk/root&amp;quot;), VVV is the Linux version code (RH9, FC3, SL4, etc) and BB is &amp;quot;_32&amp;quot; or &amp;quot;_64&amp;quot; for 32-bit or 64-bit ROOT. For example: /daq/daqshare/olchansk/root/root_v5.10.00_SL40&lt;br /&gt;
* for example: ln -s /daq/daqshare/olchansk/root/root_v5.34.34_el72_64 $HOME/packages/root&lt;br /&gt;
* Check that ROOT works: &amp;quot;source $HOME/packages/root/bin/thisroot.sh; root&amp;quot;. Type &amp;quot;.q&amp;quot; to exit root.&lt;br /&gt;
&lt;br /&gt;
== Install MIDAS ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* (OBSOLETE) svn co svn+ssh://svn@savannah.psi.ch/repos/meg/midas/trunk midas, password &amp;quot;svn&amp;quot;. (password has to be entered twice)&lt;br /&gt;
* (OBSOLETE) svn co svn+ssh://svn@savannah.psi.ch/repos/meg/mxml/trunk mxml&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/midas --recursive&lt;br /&gt;
* (OBSOLETE) git clone https://bitbucket.org/tmidas/mxml&lt;br /&gt;
* (OBSOLETE) git clone https://bitbucket.org/tmidas/mscb&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mxml.git&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mscb.git&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/midas.git&lt;br /&gt;
* cd midas&lt;br /&gt;
* make&lt;br /&gt;
* (only if needed) make linux32 ### build the 32-bit MIDAS libraries&lt;br /&gt;
* ls -l linux/bin/odbedit ### check that odbedit has been created (do not run it yet)&lt;br /&gt;
&lt;br /&gt;
You can see a list of other installation problems at [[Common problems &amp;amp; Debugging recipes]].&lt;br /&gt;
&lt;br /&gt;
;NOTE 1&lt;br /&gt;
: Optional features in MIDAS can be explicitly disabled if desired when making MIDAS using the NO_xxx feature (NO_ROOT,NO_MYSQL,NO_ODBC,NO_SQLITE,NO_MSCB), e.g. &amp;quot;make NO_ROOT=1&amp;quot; to disable ROOT. These NO_xxx Makefile variables are only used to control autodetection.&lt;br /&gt;
&lt;br /&gt;
;NOTE 2&lt;br /&gt;
: Since June 2019 the mxml and mscb packages are submodules of the midas package, so no need to clone them separately. If you have an existing clone of midas but not yet the submodules, you need&lt;br /&gt;
&lt;br /&gt;
 $ git submodule update --init --recursive&lt;br /&gt;
&lt;br /&gt;
: To update both midas and the submodules, you need&lt;br /&gt;
&lt;br /&gt;
 $ git pull --recurse-submodules&lt;br /&gt;
&lt;br /&gt;
== Install ROOTANA ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
* cd rootana&lt;br /&gt;
* make&lt;br /&gt;
&lt;br /&gt;
== Install ROODY ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/roody&lt;br /&gt;
* cd roody&lt;br /&gt;
* make&lt;br /&gt;
* $HOME/packages/roody/bin/roody, run the program&lt;br /&gt;
&lt;br /&gt;
== Install additional additional packages ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/ttriumfdaq/vme&lt;br /&gt;
* git clone https://bitbucket.org/ttriumfdaq/frontends&lt;br /&gt;
&lt;br /&gt;
== Build special versions of MIDAS ==&lt;br /&gt;
&lt;br /&gt;
Build special versions of MIDAS for the case when some MIDAS programs, such as VME frontends, will run on a different computer that may have a different flavour of operating system, i.e. 32-bit linux or an older version of Scientific Linux.&lt;br /&gt;
&lt;br /&gt;
* login to the computer where the frontends will run and:&lt;br /&gt;
* if it is a 32-bit linux: cd $HOME/packages/midas; make linux32&lt;br /&gt;
* if it is a 64-bit linux: cd $HOME/packages/midas; make linux64&lt;br /&gt;
&lt;br /&gt;
* login to the host computer to cross-compile ARM code:&lt;br /&gt;
* if it is an ARM linux: cd $HOME/packages/midas; make linuxarm # may need to install ARM cross compilers&lt;br /&gt;
&lt;br /&gt;
== Prepare VME hardware ==&lt;br /&gt;
&lt;br /&gt;
Hardware check list:&lt;br /&gt;
* VME crate&lt;br /&gt;
* VME processor (supported are V77xx, V7805, V7865)&lt;br /&gt;
* On all VME modules, set the VME address jumpers as described here: http://daq-plone.triumf.ca/SM/docs/local/vme_jumpers&lt;br /&gt;
* run vmescan to confirm correct VME addresses&lt;br /&gt;
** cd $HOME/packages&lt;br /&gt;
** svn checkout https://ladd00.triumf.ca/svn/daqsvn/trunk/vme&lt;br /&gt;
** cd vme&lt;br /&gt;
** make&lt;br /&gt;
** ./vmescan.exe (or _gef.exe, depending on the VME driver in use)&lt;br /&gt;
&lt;br /&gt;
== Install Universe-II VME driver (V7648, V7750, V7805, V7851) ==&lt;br /&gt;
&lt;br /&gt;
* login as root (ssh root@localhost)&lt;br /&gt;
* follow instructions: https://www.triumf.info/wiki/DAQwiki/index.php/VME-CPU#V7648.2C_V7750.2C_V7805.2C_V7851_:_Setup_vme_universe_VME_drivers&lt;br /&gt;
* cd ~/packages/vme; vmescan.exe&lt;br /&gt;
&lt;br /&gt;
== Install Tsi-148 VME driver (V7865) ==&lt;br /&gt;
&lt;br /&gt;
* login as root (ssh root@localhost)&lt;br /&gt;
* follow instructions: https://www.triumf.info/wiki/DAQwiki/index.php/VME-CPU#V7865_and_XVB-602_:_Setup_gefvme.2Ftsi148_VME_drivers&lt;br /&gt;
* cd ~/packages/vme; vmescan_gef.exe&lt;br /&gt;
&lt;br /&gt;
== Setup the experiment environment ==&lt;br /&gt;
&lt;br /&gt;
* Decide which computer will host MIDAS (where MIDAS shared memory buffers will reside). &lt;br /&gt;
: This computer will run the [[mserver]], [[mlogger]] and [[mhttpd]] applications. (It is usually the machine where the MIDAS,ROOT etc. packages have been downloaded). It will be referred to as the host machine (localhost).&lt;br /&gt;
&lt;br /&gt;
The environment is slightly different depending on whether all programs run on the host machine, or whether some programs run on remote host(s) : &lt;br /&gt;
=== ALL programs run on localhost ===&lt;br /&gt;
:If all programs run on the host machine (localhost), it is not necessary to run [[mserver]]. [[Environment Variables#MIDAS_SERVER_HOST|MIDAS_SERVER_HOST]] will not be assigned (see example .cshrc [[#Prepare the user account|above]]).&lt;br /&gt;
&lt;br /&gt;
=== Some programs run on REMOTE host(s) ===&lt;br /&gt;
: &#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; &lt;br /&gt;
# Since August 2015 &#039;&#039;&#039;you must explicitly allow access for clients running on remote machines&#039;&#039;&#039;. To do this, follow the &#039;&#039;&#039;[[Security#MIDAS programs on remote machines|instructions here]]&#039;&#039;&#039;.&lt;br /&gt;
# The example code .cshrc ([[#Prepare the user account|see above]]) should be present on both host and remote machine(s). This will ensure that [[Environment Variables#MIDAS_SERVER_HOST|MIDAS_SERVER_HOST]] will NOT be set for the host machine (localhost), but on a remote machine, MIDAS_SERVER_HOST will be set to the MIDAS host machine. &lt;br /&gt;
# The client [[mserver]] must be started on the MIDAS host machine. Note that multiple experiments can run on the same host machine by starting several instances of [[mserver]] (one for each experiment) running with different ports (and .cshrc would be edited so that MIDAS_SERVER_HOST is set to the appropriate port for the experiment).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
On the host machine:&lt;br /&gt;
* mkdir $HOME/online&lt;br /&gt;
* cd $HOME/online&lt;br /&gt;
* create directories for local programs, sources, elog and history: mkdir bin src elog history&lt;br /&gt;
* create data directory: mkdir -p /ladd/data1/t2kvme5/data; ln -s /ladd/data1/t2kvme5/data $HOME/online&lt;br /&gt;
* create the exptab file &amp;quot;$HOME/online/exptab&amp;quot; following the example below. The first entry (exptname) is the name if the DAQ system (MIDAS experiment name), the second entry (/home/USER/online) is the location of MIDAS shared memory buffers (by convention, $HOME/online), the third entry (kopio03) is your username.&lt;br /&gt;
&amp;lt;pre&amp;gt;exptname /home/kopio03/online kopio03&amp;lt;/pre&amp;gt;&lt;br /&gt;
* logout and login again for all changes to take effect&lt;br /&gt;
&lt;br /&gt;
== Setup experiment startup scripts ==&lt;br /&gt;
* login to the experiment host computer&lt;br /&gt;
* echo $MIDAS_SERVER_HOST ### to check correct value - should be blank&lt;br /&gt;
* create $HOME/online/bin/start_daq.sh, replacing XXX with the hostname of the machine running the experiment (and changing the mserver and mhttpd ports, as needed).&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 # start_daq.sh&lt;br /&gt;
 cd $HOME/online&lt;br /&gt;
 #&lt;br /&gt;
 case `hostname` in XXX*)&lt;br /&gt;
    echo &amp;quot;Good, we are on XXX!&amp;quot;&lt;br /&gt;
    ;;&lt;br /&gt;
 *)&lt;br /&gt;
    echo &amp;quot;The start_daq script should be executed on XXX&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
    ;;&lt;br /&gt;
 esac&lt;br /&gt;
 #&lt;br /&gt;
 odbedit -c clean&lt;br /&gt;
 #   start [[mhttpd]] on default port. (Mongoose https version - see [[mhttpd]] for other options)&lt;br /&gt;
 mhttpd  -D  -a localhost -a XXX.triumf.ca # optionally restrict access to specified hosts&lt;br /&gt;
 #&lt;br /&gt;
 #   start [[mserver]] on default port (use argument -p to use a different port) &lt;br /&gt;
 mserver -D   # access must now be specifically allowed - see [[#Setup the experiment environment|above]]&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;&lt;br /&gt;
 # OR ([[#NOTES|older MIDAS versions]])&lt;br /&gt;
 # mhttpd  -p 8081 -D -a localhost -a XXX.triumf.ca      # optionally restrict access to specified hosts&lt;br /&gt;
 # mserver -p 7071 -D -a localhost -a lxdragon01.triumf.ca -a lxdragon02.triumf.ca -a XXX.triumf.ca # optionally restrict access to specified hosts&lt;br /&gt;
 &amp;lt;/span&amp;gt;&lt;br /&gt;
 #&lt;br /&gt;
 mlogger -D&lt;br /&gt;
 #end file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Run the MIDAS Web Server ==&lt;br /&gt;
Let&#039;s start the MIDAS webserver for the first time:&lt;br /&gt;
&lt;br /&gt;
Start [[mhttpd]] on the &#039;&#039;experiment host&#039;&#039; (localhost) like this:&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&amp;lt;/small&amp;gt;&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhttpd,INFO] ODB subtree /Runinfo corrected successfully&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17892:mongoose,ERROR] cannot find SSL certificate file &amp;quot;/home/agdaq/online/ssl_cert.pem&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17893:mongoose,ERROR] please create SSL certificate file: openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key; openssl x509 -req -days 365 -sha256 -in ssl_cert.csr -signkey ssl_cert.key -out ssl_cert.pem; cat ssl_cert.key &amp;gt;&amp;gt; ssl_cert.pem&lt;br /&gt;
 could not start the mongoose web server, see messages and midas.log, bye!&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a self-signed certificate suitable for initial testing by executing the command printed by mhttpd:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 [mhostpc] openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key; openssl x509 -req -days 365 -sha256 -in ssl_cert.csr -signkey ssl_cert.key -out ssl_cert.pem; cat ssl_cert.key &amp;gt;&amp;gt; ssl_cert.pem&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For production use, you should create a properly signed certificate, see [[Mhttpd#Create an SSL certificate|create your own SSL certificate]] or you should run mhttpd behind an SSL proxy.&lt;br /&gt;
&lt;br /&gt;
Run mhttpd again.&lt;br /&gt;
&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhttpd,INFO] ODB subtree /Runinfo corrected successfully&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot;&lt;br /&gt;
 Mongoose web server will use SSL certificate file &amp;quot;/home/johnfoo/packages/midas/ssl_cert.pem&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17633:mongoose,ERROR] mongoose web server cannot find password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17634:mongoose,ERROR] please create password file: htdigest -c /home/johnfoo/online/htpasswd.txt Default midas&lt;br /&gt;
 could not start the mongoose web server, see messages and midas.log, bye!&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the password file by following the instructions printed by mhttpd. The http digest domain name is the experiment name, suggested default user name is &amp;quot;midas&amp;quot;. You will be asked to type in a password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 [mhostpc] htdigest -c /home/johnfoo/online/htpasswd.txt exptname midas&lt;br /&gt;
 Adding password for midas in realm exptname.&lt;br /&gt;
 New password:&lt;br /&gt;
 Re-type new password:&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
It is a good idea to set the password file {{Filepath|path=htpasswd.txt}} readable and writable by owner only.&lt;br /&gt;
&lt;br /&gt;
Now restart  {{Utility|name=mhttpd}}&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot; **see note&lt;br /&gt;
 Mongoose web server will use SSL certificate file &amp;quot;/home/suz/packages/midas/ssl_cert.pem&amp;quot;&lt;br /&gt;
 Mongoose web server will use authentication realm &amp;quot;Default&amp;quot;, password file &amp;quot;./htpasswd.txt&amp;quot;&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Now point a web browser running on the same host computer (localhost) to https://localhost:8443&lt;br /&gt;
If the web browser is running on a different computer, go to URL of the form&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 https://mhostpc.triumf.ca:8443  (substitute your host machine name and domain for &amp;quot;mhostpc.triumf.ca&amp;quot;)&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
If you are using the default SSL certificate you will probably get a message: &amp;quot;This Connection is Untrusted&amp;quot;.  Click &amp;quot;I understand the risks&amp;quot; and add an exception. This is because the test certificate is self-signed. Then confirm an exception. &lt;br /&gt;
&lt;br /&gt;
If instead you get a &amp;quot;connection refused&amp;quot; error, the midas host pc may have the firewall enabled. To make a firewall exception for MIDAS, follow instructions here http://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
&lt;br /&gt;
You should then see an authentication box asking you for the user name and password. The user name is &amp;quot;midas&amp;quot;. Enter the password you just created. The Midas [[Status Page]] should appear with multiple buttons for run control as well as equipment listing (no equipments will be listed as yet) and application listings. Please refer to [[mhttpd]] (the MIDAS Web-based Run Control utility) for further information. You can start and stop runs from the main status page, and use the [[ODB Page]] to access the database (ODB).&lt;br /&gt;
&lt;br /&gt;
; Note &lt;br /&gt;
: Default ports of 8080 and 8443 are used by [[mhttpd]]. If these ports are in use on your machine, start &amp;lt;span style=&amp;quot;color:darkcyan;font-style:italic&amp;quot;&amp;gt;mhttpd&amp;lt;/span&amp;gt; with alternative ports, e.g.&lt;br /&gt;
       &amp;lt;small&amp;gt;[mhostpc] mhttpd --https 8448 --http 8089&amp;lt;/small&amp;gt;&lt;br /&gt;
: or see [[Mhttpd#Usage]] to change the default ports.&lt;br /&gt;
&lt;br /&gt;
== Setup experiment database (ODB) ==&lt;br /&gt;
&lt;br /&gt;
* run $HOME/online/bin/start_daq.sh&lt;br /&gt;
&lt;br /&gt;
* odbedit, run these commands: (replace user names and directory names)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# set &amp;quot;/Logger/Message file&amp;quot; &amp;quot;/home/kopio03/online/midas.log&amp;quot; # obsolete&lt;br /&gt;
set &amp;quot;/Logger/Data Dir&amp;quot;     &amp;quot;/home/kopio03/online/data&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/History dir&amp;quot;  &amp;quot;/home/kopio03/online/history&amp;quot;&lt;br /&gt;
create STRING &amp;quot;/Logger/Elog dir&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Elog dir&amp;quot;     &amp;quot;/home/kopio03/online/elog&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/ODB dump file&amp;quot; &amp;quot;/home/kopio03/online/history/run%05d.xml&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/ODB dump&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Filename&amp;quot; &amp;quot;run%05dsub%03d.mid.gz&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Subrun byte limit&amp;quot; &amp;quot;1000000000&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Compression&amp;quot;   1&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/ODB Dump&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/Logger/Required&amp;quot; y&lt;br /&gt;
set &amp;quot;/Programs/Logger/Start command&amp;quot; &amp;quot;mlogger -D&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/fevme/Required&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/fevme/Start command&amp;quot; &amp;quot;ssh -n lxdaq09 $HOME/online/src/fevme_gef.exe -O&amp;quot;&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* open web browser e.g. firefox.&lt;br /&gt;
* go to the midas status page at https://localhost:8443  (default port). &lt;br /&gt;
** if running [[mhttpd]] with Mongoose HTTPS/OpenSSL (the default) for the first time, you will need to create a password file. Follow the instructions (see [[mhttpd#HTTPS/SSL server (Mongoose)]] for details).&lt;br /&gt;
** For other options (i.e. HTTPS/SSL proxy) see [[#Secure MIDAS and ELOG Web access]] &lt;br /&gt;
*&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;OR open the midas status page at http://localhost:8081 ([[#NOTES|older MIDAS versions]])&lt;br /&gt;
* midas status page will show most stuff &amp;quot;red&amp;quot; as nothing is running yet&lt;br /&gt;
* DON&#039;T DO THIS YET run ./fevme.exe (on the computer with the VME interface, could be different from computer hosting the experiment), observe that corresponding equipments have been created&lt;br /&gt;
* save the url bookmark to the &amp;quot;personal toolbar&amp;quot;&lt;br /&gt;
* go to the Programs page, stop mlogger, stop fevme, start mlogger, start fevme&lt;br /&gt;
* go to the Status page, start run, stop run&lt;br /&gt;
* go back to the Status page, everything should be green&lt;br /&gt;
* start a run&lt;br /&gt;
* send signals to the ADC gate&lt;br /&gt;
* you should be getting events&lt;br /&gt;
* to look at data, proceed with setting up the [[ROOTANA|ROOT Analyzer]].&lt;br /&gt;
&lt;br /&gt;
== Start DAQ programs at boot time ==&lt;br /&gt;
&lt;br /&gt;
* add this to /etc/rc.local (replace username and location of the start_daq script)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
su - alpha -c /home/alpha/online/bin/start_daq.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setup local software version control ==&lt;br /&gt;
&lt;br /&gt;
Version control for experiment source code is setup using &amp;quot;git&amp;quot; (http://git-scm.com/)&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/online&lt;br /&gt;
* git init&lt;br /&gt;
* git add exptab&lt;br /&gt;
* git add bin/start_daq.sh&lt;br /&gt;
* git add .gitignore ### contents can be&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
*~&lt;br /&gt;
*.o&lt;br /&gt;
*.exe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* git add src/Makefile src/*.cxx ...&lt;br /&gt;
* git commit -a&lt;br /&gt;
&lt;br /&gt;
== Adjust MIDAS buffer sizes ==&lt;br /&gt;
&lt;br /&gt;
Default MIDAS SYSTEM buffer size is 8 Mbytes, fairly small for high-data-rate experiments. The rule of thumb is to have at least a few seconds worth of buffer space available. For example, if event size is 10 Kbytes and the event rate is 1 kHz, data rate is 10*10^3*1*10^3 = 10 Mbytes/sec. To buffer 10 seconds of data we need 100 Mbytes of buffer space.&lt;br /&gt;
&lt;br /&gt;
To resize the MIDAS event buffers (SYSTEM, etc) do this:&lt;br /&gt;
* stop all frontends, stop mlogger&lt;br /&gt;
* start odbedit:&lt;br /&gt;
** cd &amp;quot;/Experiment/Buffer sizes&amp;quot;&lt;br /&gt;
** set SYSTEM 100000000&lt;br /&gt;
* run &amp;quot;mdump -z SYSTEM&amp;quot;&lt;br /&gt;
* if mdump complains about the size of .SYSTEM.SHM, remove it, try again.&lt;br /&gt;
* ls -l /dev/shm ### to observe that the size of shared memory is correct&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Secure MIDAS and ELOG Web access  ==&lt;br /&gt;
In versions prior to May 2015, the default web access to MIDAS and ELOG uses the &amp;quot;http:&amp;quot; protocol which is insecure. In this case, all information is transmitted as clear text meaning that secret, confidential and sensitive information (such as the MIDAS and ELOG passwords and usernames) can be stolen &amp;quot;easily&amp;quot;. This means that even &amp;quot;password protected&amp;quot; MIDAS and ELOG pages are not really protected if accessed using the &amp;quot;http&amp;quot; method. &lt;br /&gt;
 &lt;br /&gt;
Better security for HTTP is gained by using a password protected &#039;&#039;&#039;SSL (https) proxy&#039;&#039;&#039;. (It does not provide absolute security because of remaining problems with the security of SSL certificates, security of passwords, etc). Setting up an SSL (https) proxy is described [[#Setting up an HTTP proxy|below]].&lt;br /&gt;
&lt;br /&gt;
Since May 2015, an &#039;&#039;alternative secure option&#039;&#039; to setting up an HTTP proxy is available to users of MIDAS. Recent versions of elogd (ELOG) do support SSL https:// connections, and [[#mhttpd with HTTPS/SSL server (Mongoose)]] is now available.  This option is the default, and provides a similar level of security to an HTTP proxy. &lt;br /&gt;
&lt;br /&gt;
See [[Security#Web Access]] for a comparison of these two secure options.&lt;br /&gt;
  &lt;br /&gt;
=== mhttpd with HTTPS/SSL server (Mongoose) ===&lt;br /&gt;
&lt;br /&gt;
Since May 2015 the MIDAS web server [[mhttpd]] is explicitly linked with OpenSSL to provide secure HTTPS connections via the [https://bitbucket.org/tmidas/midas/src/ecb9a8537448a8a43f7f9a2bfdb82e578208cde3/doc/mongoose/?at=develop Mongoose] web server (see [[mhttpd]]). With this version, default web access to MIDAS uses the &amp;quot;https&amp;quot; protocol. Web access to {{Utility|name=mhttpd}} can be restricted by using the  &amp;quot;-a hostname&amp;quot; switch of [[mhttpd]]. The first time {{Utility|name=mhttpd}} is run, a password file must be created. An SSL certificate is also required. See [[mhttpd#HTTPS/SSL server (Mongoose)|HTTPS/SSL server (Mongoose)]] for instructions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== mhttpd using an HTTPS/SSL proxy ===&lt;br /&gt;
&lt;br /&gt;
THESE INSTRUCTIONS ARE WRONG, DO NOT DO THIS. See instead [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MIDAS_experiment_at_TRIUMF#Install_https_proxy this section].&lt;br /&gt;
&lt;br /&gt;
An [[#Setting up an HTTP proxy|HTTP proxy]] must be set up. This is the only way of securing older version of [[mhttpd]] (pre August 2015). Older versions of mhttpd are started using the -p port option  e.g.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt; mhttpd  -D -p 8080  &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run a new version of mhttpd using an HTTP proxy, use the options provided to run the old (non-Mongoose) webserver on a given port, i.e.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;  mhttpd --oldserver 8080 --nomg   -D  &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using an SSL proxy, only access from the SSL proxy (and maybe some special trusted machines) should be permitted. &lt;br /&gt;
This is done using the &amp;quot;-a hostname&amp;quot; switch of [[mhttpd]]. Normally there will be only &amp;quot;-a localhost&amp;quot; switch, enabling access only for the local machine (where the SSL proxy is running). Additional &amp;quot;-a hostname&amp;quot; switches enable access from listed local machines. No &amp;quot;-a xxx&amp;quot; enables access from everywhere (defeating the purpose of the SSL proxy, unless access controls are enforced elsewhere, i.e. by a site firewall or by local firewall rules).&lt;br /&gt;
&lt;br /&gt;
== Setting up an HTTP proxy ==&lt;br /&gt;
In this example, we use APACHE HTTPD to password-protect a typical midas/mhttpd and elog installation.&lt;br /&gt;
&lt;br /&gt;
In this configuration, one uses the Linux stock httpd that accepts encrypted https:// connections and forwards them to mhttpd and elogd. Instead of (or in addition to) using mhttpd and elogd passwords, one configures password protection in httpd via the regular apache httpd password mechanisms (htpasswd, etc).&lt;br /&gt;
&lt;br /&gt;
Recent versions of elogd do support SSL https:// connections, but if one is running an SSL proxy for anyway, it is simpler to run both through the same SSL proxy using the same SSL host certificate and the same httpd password file.&lt;br /&gt;
&lt;br /&gt;
=== Restricting http: access to elogd ===&lt;br /&gt;
;Note&lt;br /&gt;
:Recent versions of elogd do support SSL https:// connections. The following information is for those using an HTTP proxy (see above).&lt;br /&gt;
&lt;br /&gt;
For elogd, this is done using the &amp;quot;-n localhost&amp;quot; switch with enables only access from the same machine if present, or access from anywhere is absent (defeating the purpose of the SSL proxy, unless access controls are enforced elsewhere).&lt;br /&gt;
&lt;br /&gt;
(It is recommended to run elogd from the same user as the main daq user and to keep elogd.cfg and all logbooks in the home directory of this user, where they are captured by the normal site backup system)&lt;br /&gt;
&lt;br /&gt;
== Install standalone elog ==&lt;br /&gt;
&lt;br /&gt;
* login into the user account that will run the elog&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/ritt/elog&lt;br /&gt;
* cd elog&lt;br /&gt;
* make&lt;br /&gt;
* create new file start_elogd with this contents:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
killall elogd&lt;br /&gt;
sleep 1&lt;br /&gt;
killall -KILL elogd&lt;br /&gt;
sleep 1&lt;br /&gt;
$HOME/packages/elog/elogd -n localhost -x -c $HOME/packages/elog/elogd.cfg -p 8082 -D&lt;br /&gt;
&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* chmod a+x start_elogd&lt;br /&gt;
* edit elogd.cfg to read:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[global]&lt;br /&gt;
port = 8082&lt;br /&gt;
SMTP host = smtp.triumf.ca&lt;br /&gt;
URL = https://titan00.triumf.ca/elog/&lt;br /&gt;
&lt;br /&gt;
Reverse sort = 1&lt;br /&gt;
Display Mode = full&lt;br /&gt;
&lt;br /&gt;
#List Menu commands = New, Find, Admin, Help&lt;br /&gt;
#Menu commands = New, Edit, Reply, Find, Duplicate, Help&lt;br /&gt;
&lt;br /&gt;
Entries Per Page = 30&lt;br /&gt;
Supress Email on edit = 1&lt;br /&gt;
Default encoding = 1&lt;br /&gt;
Page title = TITAN ELOG&lt;br /&gt;
Resolve host names = 1&lt;br /&gt;
&lt;br /&gt;
Logfile = /home/titan/packages/elog/elogd.log&lt;br /&gt;
#Logging level = 3&lt;br /&gt;
&lt;br /&gt;
[midas]&lt;br /&gt;
&lt;br /&gt;
List page Title = T2K M11 MIDAS ELOG&lt;br /&gt;
Comment = T2K M11 MIDAS ELOG&lt;br /&gt;
Page Title = T2K M11 MIDAS ELOG&lt;br /&gt;
RSS Title = [$logbook - $type - $system] $subject, posted by $author&lt;br /&gt;
&lt;br /&gt;
Attributes = Author, Subject, Run, Type, System&lt;br /&gt;
Show Attributes Edit = Run, Author, Subject, Type, System&lt;br /&gt;
Required Attributes = Author, Type, System, Subject&lt;br /&gt;
&lt;br /&gt;
Options Type = Routine, Reply, Shift Summary, Modification, Question, Info, Problem&lt;br /&gt;
Options System = General, DAQ, Beamline&lt;br /&gt;
&lt;br /&gt;
Preset Run = $shell(MIDASSYS=. /home/t2km11/packages/midas/linux/bin/odbedit -d Runinfo -c &#039;ls -v \&amp;quot;run number\&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
Preset On Reply Type = Reply&lt;br /&gt;
Preset On Reply Run = $shell(MIDASSYS=. /home/t2km11/packages/midas/linux/bin/odbedit -d Runinfo -c &#039;ls -v \&amp;quot;run number\&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
List Display = Date, Subject, Type, System, Author, ID&lt;br /&gt;
Quick Filter = Date, Type, ID&lt;br /&gt;
&lt;br /&gt;
Remove on reply = Author&lt;br /&gt;
Quote on reply = 1&lt;br /&gt;
&lt;br /&gt;
Use lock = 1&lt;br /&gt;
&lt;br /&gt;
************* Email Functionality ****************&lt;br /&gt;
&lt;br /&gt;
Use Email Subject = [T2KM11 - $System] $Subject&lt;br /&gt;
Omit Email To = 1&lt;br /&gt;
&lt;br /&gt;
Email System General = xxx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* ./start_elogd &amp;amp;&lt;br /&gt;
* firefox http://localhost:8082 # hould show the elog message index&lt;br /&gt;
&lt;br /&gt;
To start elogd automatically when the machine is rebooted, login as root and&lt;br /&gt;
* add this text to /etc/rc.local:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
su - titan -c &amp;quot;/home/titan/packages/elog/start_elogd&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* chmod a+x /etc/rc.local&lt;br /&gt;
* systemctl start rc-local&lt;br /&gt;
&lt;br /&gt;
To import elog entries from the mhttpd elog, do this:&lt;br /&gt;
&lt;br /&gt;
* cd ~/packages/elog/logbooks&lt;br /&gt;
* ln -s /home/t2km11/online/elog midas&lt;br /&gt;
* cd midas&lt;br /&gt;
* ~/packages/elog/elconv)&lt;br /&gt;
&lt;br /&gt;
== Install https proxy ==&lt;br /&gt;
&lt;br /&gt;
THESE INSTRUCTIONS ARE OBSOLETE, INSTEAD, &lt;br /&gt;
* GO HERE: https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog&lt;br /&gt;
* AND GO HERE: https://midas.triumf.ca/MidasWiki/index.php/Quickstart_Linux#Run_the_MIDAS_Web_Server&lt;br /&gt;
&lt;br /&gt;
FOLLOWING INSTRUCTIONS ARE OBSOLETE...&lt;br /&gt;
&lt;br /&gt;
* login as root to the https proxy machine&lt;br /&gt;
* cd ~root&lt;br /&gt;
* yum install mod_ssl&lt;br /&gt;
* yum install crypto-utils # see http://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_monitoring_of_HTTPS_certificates&lt;br /&gt;
* create a certificate request (replace ladd09 with your hostname): openssl req -new -nodes -newkey rsa:2048 -sha256 -out ladd09.csr -keyout ladd09.key (answer: CA, BC, Vancouver, TRIUMF, DAQ, ladd09.triumf.ca, email@email.com&lt;br /&gt;
* sign it by TRIUMF:&lt;br /&gt;
** mail -s &amp;quot;Certificate request&amp;quot; yourself@email.com &amp;amp;lt; ladd09.csr&lt;br /&gt;
** forward this request to Andrew Daviel&lt;br /&gt;
** he will email the signed crt file, copy it to this system as ladd09.crt&lt;br /&gt;
* sign it yourself: openssl x509 -req -days 365 -sha256 -in ladd09.csr -signkey ladd09.key -out ladd09.crt&lt;br /&gt;
* (if the certificate expires, renew it by signing it again)&lt;br /&gt;
* Additional commands for working with certificates:&lt;br /&gt;
** explore the private key: openssl pkey -in ladd09.key -text -noout&lt;br /&gt;
** explore the certificate request: openssl req -in ladd00.csr -text -noout&lt;br /&gt;
** explore the certificate: openssl x509 -in ladd09.crt -noout -text&lt;br /&gt;
* move certificate files to proper system locations:&lt;br /&gt;
* mv ladd09.key  /etc/pki/tls/private/&lt;br /&gt;
* mv ladd09.crt /etc/pki/tls/certs/&lt;br /&gt;
* if selinux is enabled, do this:&lt;br /&gt;
** restorecon -Rv /etc/pki/tls/certs/&lt;br /&gt;
** restorecon -Rv /etc/pki/tls/private/&lt;br /&gt;
** /usr/sbin/setsebool -P httpd_can_network_connect 1&lt;br /&gt;
* open /etc/httpd/conf.d/ssl.conf in a text editor, go to the very bottom and right before the &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; entry, add following text:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SSLCertificateFile /etc/pki/tls/certs/ladd09.crt &lt;br /&gt;
SSLCertificateKeyFile /etc/pki/tls/private/ladd09.key &lt;br /&gt;
&lt;br /&gt;
ProxyPass /elog/ http://localhost:8082/ retry=1&lt;br /&gt;
ProxyPass /      http://localhost:8080/ retry=1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Location /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SSLRequireSSL&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthName &amp;quot;password protected site&amp;quot;&lt;br /&gt;
Require valid-user&lt;br /&gt;
&lt;br /&gt;
# create password file: touch /etc/httpd/htpasswd&lt;br /&gt;
# to add new user or change password: htpasswd /etc/httpd/htpasswd username&lt;br /&gt;
AuthUserFile /etc/httpd/htpasswd&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/Location&amp;gt;&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* comment out duplicate &amp;quot;SSLCertificateFile&amp;quot; and &amp;quot;SSLCertificateKeyFile&amp;quot; elsewhere in the file&lt;br /&gt;
* (optionally) If you got a certificate that is signed by DigiCert or RapidSSL then you&#039;ll need to add a line specifying the certificate chain file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SSLCertificateChainFile /etc/pki/tls/certs/DigiCertCA.crt&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* touch /etc/httpd/htpasswd&lt;br /&gt;
* htpasswd /etc/httpd/htpasswd midas # enter password midas&lt;br /&gt;
* chkconfig httpd on&lt;br /&gt;
* service httpd restart&lt;br /&gt;
* firewall-cmd --add-port=443/tcp --permanent&lt;br /&gt;
* firewall-cmd --reload&lt;br /&gt;
* firewall-cmd --list-all&lt;br /&gt;
* test it&lt;br /&gt;
** test the SSL proxy: https://host/ should yield the midas status page, https://host/elog/ should yield the elog message index&lt;br /&gt;
* in ODB, set &amp;quot;/Elog/URL&amp;quot; to &amp;quot;https://host/elog/&amp;quot;&lt;br /&gt;
* now from the midas status page, the &amp;quot;Elog&amp;quot; button should take us to the https Elog URL&lt;br /&gt;
&lt;br /&gt;
In needed, enable user directories: https://blah/~user in ~user/public_html&lt;br /&gt;
&lt;br /&gt;
* edit /etc/httpd/conf.d/userdir.conf, replace &amp;quot;UserDir disabled&amp;quot; with &amp;quot;UserDir enabled&amp;quot;&lt;br /&gt;
* setsebool -P httpd_enable_homedirs true&lt;br /&gt;
* systemctl restart httpd&lt;br /&gt;
&lt;br /&gt;
== Setup the history mhttpd for faster access to history plots ==&lt;br /&gt;
When running an SSL proxy,&lt;br /&gt;
* start the main mhttpd (&amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;orange&amp;lt;/span&amp;gt; command for old mhttpd, &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;green&amp;lt;/span&amp;gt; for new mhttpd with Mongoose(post August2015):&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8071 -D&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D --oldserver 8071 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* start the history mhttpd&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt; &amp;quot;mhttpd -p 8072 -D -H&amp;quot;&amp;lt;/span&amp;gt; or&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D -H --oldserver 8072 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
* set ODB /History/URL to &amp;quot;http://alphacpc09.cern.ch:8072/HS/&amp;quot;&lt;br /&gt;
* open the MIDAS status page&lt;br /&gt;
* go to the history section, try to open any history plot, observe that the history plot gif image loads correctly, inspect it&#039;s URL (use &amp;quot;copy image URL&amp;quot; or &amp;quot;view source&amp;quot;, etc), it should point to port 8072 causing connection to the history mhttpd.&lt;br /&gt;
* continue with these instructions to setup history mhttpd access through an SSL proxy:&lt;br /&gt;
* setup SSL proxy access (required mod_proxy_html)&lt;br /&gt;
** login as root to the SSL proxy machine&lt;br /&gt;
** on SL5, install the missing mod_proxy_html httpd module:&lt;br /&gt;
** yum install httpd-devel libxml2-devel&lt;br /&gt;
** wget http://apache.webthing.com/mod_proxy_html/mod_proxy_html.tar.bz2&lt;br /&gt;
** tar xjvf mod_proxy_html.tar.bz2 &lt;br /&gt;
** cd mod_proxy_html&lt;br /&gt;
** apxs -c -I. -I/usr/include/libxml2 -i mod_proxy_html.c &lt;br /&gt;
** apxs -c -I. -I/usr/include/libxml2 -i mod_xml2enc.c&lt;br /&gt;
** cd /etc/httpd/conf.d, add this to ssl.conf:&lt;br /&gt;
&lt;br /&gt;
;before the ProxyPass statements:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# proxy the MIDAS web servers  &lt;br /&gt;
LoadModule  xml2enc_module       modules/mod_xml2enc.so  &lt;br /&gt;
LoadModule  proxy_html_module    modules/mod_proxy_html.so  &lt;br /&gt;
ProxyHTMLLinks  a               href  &lt;br /&gt;
ProxyHTMLLinks  link            href  &lt;br /&gt;
ProxyHTMLLinks  img             src  &lt;br /&gt;
#ProxyHTMLEnable On  &lt;br /&gt;
ProxyRequests off  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
;after the ProxyPass statements:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ALPHA1 history access &lt;br /&gt;
ProxyPass /alpha1/history/   http://alphacpc09.cern.ch:8072/HS/  retry=1 &lt;br /&gt;
ProxyPass /alpha1/           http://alphacpc09.cern.ch:8071/     retry=1 &lt;br /&gt;
 &lt;br /&gt;
ProxyHTMLEnable On  &lt;br /&gt;
ProxyHTMLURLMap http://alphacpc09.cern.ch:8072/HS/ /alpha1/history/ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
;adjust:&lt;br /&gt;
*&amp;quot;alpha1&amp;quot; is the experiment name&lt;br /&gt;
*&amp;quot;alphacpc09.cern.ch&amp;quot; is the machine running mhttpd&lt;br /&gt;
*&amp;quot;8071&amp;quot; is the port number of the main mhttpd &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8071 -D&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D --oldserver 8071 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
* &amp;quot;8072&amp;quot; is the port number of the history mhttpd &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8072 -D -H&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D -H --oldserver 8072 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]] [[Category:Buffer]] [[Category:Driver]]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MIDAS_experiment_at_TRIUMF&amp;diff=3605</id>
		<title>Setup MIDAS experiment at TRIUMF</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MIDAS_experiment_at_TRIUMF&amp;diff=3605"/>
		<updated>2026-03-12T20:46:59Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setup experiment database (ODB) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This page describes setting up a MIDAS experiment at TRIUMF. This information can be adapted for other sites.&lt;br /&gt;
&lt;br /&gt;
== Environment variables ==&lt;br /&gt;
* &#039;&#039;&#039;MIDASSYS&#039;&#039;&#039; Base directory of the MIDAS package, midas and mxml should be at the same level.&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_EXPTAB&#039;&#039;&#039; Experiment definition file&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_SERVER_HOST&#039;&#039;&#039; MIDAS host server name for remote midas connections.&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_EXPT_NAME&#039;&#039;&#039; Experiment name&lt;br /&gt;
&lt;br /&gt;
== Standard layout of MIDAS experiment ==&lt;br /&gt;
The following shows the directory layout of a standard MIDAS experiment: &lt;br /&gt;
&lt;br /&gt;
 /home/exptuser/&lt;br /&gt;
                packages/&lt;br /&gt;
                        root                   &amp;lt;---- ROOT&lt;br /&gt;
                        mxml&lt;br /&gt;
                        mscb&lt;br /&gt;
                        midas/                 &amp;lt;---- MIDAS&lt;br /&gt;
                              linux/{lib,bin}       &amp;lt;---- binaries matching the selected 64-bit/32-bit flavour of ROOT&lt;br /&gt;
                              linux-m32/{lib,bin}   &amp;lt;---- limited function 32-bit binaries for 32-bit frontend machines, build by &amp;quot;make linux32&amp;quot;&lt;br /&gt;
                              linux-m64/{lib,bin}   &amp;lt;---- limited function 64-bit binaries (only needed if ROOT and linux/bin are 32-bit)&lt;br /&gt;
                              linux-arm/{lib,bin}   &amp;lt;---- full function ARM cross-compiled using &amp;quot;make linuxarm&amp;quot;&lt;br /&gt;
                              linux-crosscompile/{lib,bin}  &amp;lt;---- cross-compiled limited function binaries for PPC and ARM frontends (see Makefile)&lt;br /&gt;
                        rootana                &amp;lt;---- ROOT analyzer&lt;br /&gt;
                        roody                  &amp;lt;---- graphical online histogram viewer for MIDAS and ROOTANA&lt;br /&gt;
                 online/&lt;br /&gt;
                        exptab                         &amp;lt;---- experiment definition&lt;br /&gt;
                        {.ODB,.SYSTEM,.SYSMSG,etc}.SHM &amp;lt;---- MIDAS shared memory save files&lt;br /&gt;
                        src                            &amp;lt;---- experiment frontend sources&lt;br /&gt;
                        bin,scripts&lt;br /&gt;
                        elog                           &amp;lt;---- MIDAS elog&lt;br /&gt;
                        history                        &amp;lt;---- MIDAS history&lt;br /&gt;
                        data -&amp;gt; /data/exptname/current &amp;lt;---- symlink to the data directory&lt;br /&gt;
 /data/exptname/current                                &amp;lt;---- experiment data directory with ODB save files and MIDAS .mid/.mid.gz data files&lt;br /&gt;
&lt;br /&gt;
== Prepare computers ==&lt;br /&gt;
&lt;br /&gt;
On some operating systems, several MIDAS functions require administrator access:&lt;br /&gt;
&lt;br /&gt;
* on el7 linux (SL7/CC7/CentOS7/RHEL7) - access to mhttpd port 8443 requires special firewall rules, see here: https://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
* on el7 linux - access to mserver to run frontends and other programs on some other computer requires special firewall rules, see here: https://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
* on el7 linux - on the frontend machines (and other machines that will connect to the mserver, the same firewall rule needs to be created (use the IP address of the machine running the mserver)&lt;br /&gt;
&lt;br /&gt;
== Prepare the user account ==&lt;br /&gt;
&amp;lt;div id=&amp;quot;NOTES&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Setup the user account for running this instance of midas. For machines part of the LADD cluster, follow these  [http://daq-plone.triumf.ca/SM/docs/local/NewLaddUser] instructions.&lt;br /&gt;
* check that the account is using the /bin/bash shell&lt;br /&gt;
* make $HOME/.profile look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/echo You must source&lt;br /&gt;
&lt;br /&gt;
export SVN_EDITOR=&amp;quot;emacs -nw&amp;quot;&lt;br /&gt;
export GIT_EDITOR=&amp;quot;emacs -nw&amp;quot;&lt;br /&gt;
export MIDASSYS=$HOME/packages/midas&lt;br /&gt;
export ROOTANASYS=$HOME/packages/rootana&lt;br /&gt;
export MIDAS_EXPTAB=$HOME/online/exptab&lt;br /&gt;
#&lt;br /&gt;
# setup the MIDAS mserver&lt;br /&gt;
#&lt;br /&gt;
case `hostname` in&lt;br /&gt;
daq07*)&lt;br /&gt;
   unset MIDAS_SERVER_HOST&lt;br /&gt;
   ;;&lt;br /&gt;
*)&lt;br /&gt;
   export MIDAS_SERVER_HOST=daq07.triumf.ca:7070&lt;br /&gt;
   ;;&lt;br /&gt;
esac&lt;br /&gt;
#&lt;br /&gt;
# select 64-bit or 32-bit MIDAS and ROOT&lt;br /&gt;
#&lt;br /&gt;
case `uname -i` in&lt;br /&gt;
i386)&lt;br /&gt;
   source /daq/daqshare/olchansk/root/root_v5.34.01_SL62_32/bin/thisroot.sh&lt;br /&gt;
   export PATH=.:$MIDASSYS/linux-m32/bin:$PATH&lt;br /&gt;
   ;;&lt;br /&gt;
*)&lt;br /&gt;
   #source /daq/daqshare/olchansk/root/root_v5.34.34_SL67_64/bin/thisroot.sh&lt;br /&gt;
   source $HOME/packages/root/bin/thisroot.sh&lt;br /&gt;
   export PATH=.:$MIDASSYS/linux/bin:$PATH&lt;br /&gt;
   ;;&lt;br /&gt;
esac&lt;br /&gt;
#&lt;br /&gt;
export PATH=.:$HOME/online/bin:$HOME/packages/roody/bin:$PATH&lt;br /&gt;
#&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* mkdir $HOME/packages&lt;br /&gt;
* Logout and login again, for .cshrc changes to take effect&lt;br /&gt;
&lt;br /&gt;
== Install ROOT ==&lt;br /&gt;
&lt;br /&gt;
* Identify the Linux version: RH9 (Red Hat Linux 9), FC3 (Fedora Core 3), RHEL4/SL4 (Red Hat Enterprise LInux 4/Scientific Linux 4), SL5x, SL6x, (CentOS/CC/SL) el7x: more /etc/redhat-release&lt;br /&gt;
* Decide to use 32-bit or 64-bit ROOT (&#039;uname -a&#039;)&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* ls -l /daq/daqshare/olchansk/root/ ### to see all available ROOT packages&lt;br /&gt;
* ln -s /daq/daqshare/olchansk/root/root_vNNN_VVV_BB root, where NNN is the latest available version of ROOT (&amp;quot;ls -l /daq/daqshare/olchansk/root&amp;quot;), VVV is the Linux version code (RH9, FC3, SL4, etc) and BB is &amp;quot;_32&amp;quot; or &amp;quot;_64&amp;quot; for 32-bit or 64-bit ROOT. For example: /daq/daqshare/olchansk/root/root_v5.10.00_SL40&lt;br /&gt;
* for example: ln -s /daq/daqshare/olchansk/root/root_v5.34.34_el72_64 $HOME/packages/root&lt;br /&gt;
* Check that ROOT works: &amp;quot;source $HOME/packages/root/bin/thisroot.sh; root&amp;quot;. Type &amp;quot;.q&amp;quot; to exit root.&lt;br /&gt;
&lt;br /&gt;
== Install MIDAS ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* (OBSOLETE) svn co svn+ssh://svn@savannah.psi.ch/repos/meg/midas/trunk midas, password &amp;quot;svn&amp;quot;. (password has to be entered twice)&lt;br /&gt;
* (OBSOLETE) svn co svn+ssh://svn@savannah.psi.ch/repos/meg/mxml/trunk mxml&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/midas --recursive&lt;br /&gt;
* (OBSOLETE) git clone https://bitbucket.org/tmidas/mxml&lt;br /&gt;
* (OBSOLETE) git clone https://bitbucket.org/tmidas/mscb&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mxml.git&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mscb.git&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/midas.git&lt;br /&gt;
* cd midas&lt;br /&gt;
* make&lt;br /&gt;
* (only if needed) make linux32 ### build the 32-bit MIDAS libraries&lt;br /&gt;
* ls -l linux/bin/odbedit ### check that odbedit has been created (do not run it yet)&lt;br /&gt;
&lt;br /&gt;
You can see a list of other installation problems at [[Common problems &amp;amp; Debugging recipes]].&lt;br /&gt;
&lt;br /&gt;
;NOTE 1&lt;br /&gt;
: Optional features in MIDAS can be explicitly disabled if desired when making MIDAS using the NO_xxx feature (NO_ROOT,NO_MYSQL,NO_ODBC,NO_SQLITE,NO_MSCB), e.g. &amp;quot;make NO_ROOT=1&amp;quot; to disable ROOT. These NO_xxx Makefile variables are only used to control autodetection.&lt;br /&gt;
&lt;br /&gt;
;NOTE 2&lt;br /&gt;
: Since June 2019 the mxml and mscb packages are submodules of the midas package, so no need to clone them separately. If you have an existing clone of midas but not yet the submodules, you need&lt;br /&gt;
&lt;br /&gt;
 $ git submodule update --init --recursive&lt;br /&gt;
&lt;br /&gt;
: To update both midas and the submodules, you need&lt;br /&gt;
&lt;br /&gt;
 $ git pull --recurse-submodules&lt;br /&gt;
&lt;br /&gt;
== Install ROOTANA ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
* cd rootana&lt;br /&gt;
* make&lt;br /&gt;
&lt;br /&gt;
== Install ROODY ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/roody&lt;br /&gt;
* cd roody&lt;br /&gt;
* make&lt;br /&gt;
* $HOME/packages/roody/bin/roody, run the program&lt;br /&gt;
&lt;br /&gt;
== Install additional additional packages ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/ttriumfdaq/vme&lt;br /&gt;
* git clone https://bitbucket.org/ttriumfdaq/frontends&lt;br /&gt;
&lt;br /&gt;
== Build special versions of MIDAS ==&lt;br /&gt;
&lt;br /&gt;
Build special versions of MIDAS for the case when some MIDAS programs, such as VME frontends, will run on a different computer that may have a different flavour of operating system, i.e. 32-bit linux or an older version of Scientific Linux.&lt;br /&gt;
&lt;br /&gt;
* login to the computer where the frontends will run and:&lt;br /&gt;
* if it is a 32-bit linux: cd $HOME/packages/midas; make linux32&lt;br /&gt;
* if it is a 64-bit linux: cd $HOME/packages/midas; make linux64&lt;br /&gt;
&lt;br /&gt;
* login to the host computer to cross-compile ARM code:&lt;br /&gt;
* if it is an ARM linux: cd $HOME/packages/midas; make linuxarm # may need to install ARM cross compilers&lt;br /&gt;
&lt;br /&gt;
== Prepare VME hardware ==&lt;br /&gt;
&lt;br /&gt;
Hardware check list:&lt;br /&gt;
* VME crate&lt;br /&gt;
* VME processor (supported are V77xx, V7805, V7865)&lt;br /&gt;
* On all VME modules, set the VME address jumpers as described here: http://daq-plone.triumf.ca/SM/docs/local/vme_jumpers&lt;br /&gt;
* run vmescan to confirm correct VME addresses&lt;br /&gt;
** cd $HOME/packages&lt;br /&gt;
** svn checkout https://ladd00.triumf.ca/svn/daqsvn/trunk/vme&lt;br /&gt;
** cd vme&lt;br /&gt;
** make&lt;br /&gt;
** ./vmescan.exe (or _gef.exe, depending on the VME driver in use)&lt;br /&gt;
&lt;br /&gt;
== Install Universe-II VME driver (V7648, V7750, V7805, V7851) ==&lt;br /&gt;
&lt;br /&gt;
* login as root (ssh root@localhost)&lt;br /&gt;
* follow instructions: https://www.triumf.info/wiki/DAQwiki/index.php/VME-CPU#V7648.2C_V7750.2C_V7805.2C_V7851_:_Setup_vme_universe_VME_drivers&lt;br /&gt;
* cd ~/packages/vme; vmescan.exe&lt;br /&gt;
&lt;br /&gt;
== Install Tsi-148 VME driver (V7865) ==&lt;br /&gt;
&lt;br /&gt;
* login as root (ssh root@localhost)&lt;br /&gt;
* follow instructions: https://www.triumf.info/wiki/DAQwiki/index.php/VME-CPU#V7865_and_XVB-602_:_Setup_gefvme.2Ftsi148_VME_drivers&lt;br /&gt;
* cd ~/packages/vme; vmescan_gef.exe&lt;br /&gt;
&lt;br /&gt;
== Setup the experiment environment ==&lt;br /&gt;
&lt;br /&gt;
* Decide which computer will host MIDAS (where MIDAS shared memory buffers will reside). &lt;br /&gt;
: This computer will run the [[mserver]], [[mlogger]] and [[mhttpd]] applications. (It is usually the machine where the MIDAS,ROOT etc. packages have been downloaded). It will be referred to as the host machine (localhost).&lt;br /&gt;
&lt;br /&gt;
The environment is slightly different depending on whether all programs run on the host machine, or whether some programs run on remote host(s) : &lt;br /&gt;
=== ALL programs run on localhost ===&lt;br /&gt;
:If all programs run on the host machine (localhost), it is not necessary to run [[mserver]]. [[Environment Variables#MIDAS_SERVER_HOST|MIDAS_SERVER_HOST]] will not be assigned (see example .cshrc [[#Prepare the user account|above]]).&lt;br /&gt;
&lt;br /&gt;
=== Some programs run on REMOTE host(s) ===&lt;br /&gt;
: &#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; &lt;br /&gt;
# Since August 2015 &#039;&#039;&#039;you must explicitly allow access for clients running on remote machines&#039;&#039;&#039;. To do this, follow the &#039;&#039;&#039;[[Security#MIDAS programs on remote machines|instructions here]]&#039;&#039;&#039;.&lt;br /&gt;
# The example code .cshrc ([[#Prepare the user account|see above]]) should be present on both host and remote machine(s). This will ensure that [[Environment Variables#MIDAS_SERVER_HOST|MIDAS_SERVER_HOST]] will NOT be set for the host machine (localhost), but on a remote machine, MIDAS_SERVER_HOST will be set to the MIDAS host machine. &lt;br /&gt;
# The client [[mserver]] must be started on the MIDAS host machine. Note that multiple experiments can run on the same host machine by starting several instances of [[mserver]] (one for each experiment) running with different ports (and .cshrc would be edited so that MIDAS_SERVER_HOST is set to the appropriate port for the experiment).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
On the host machine:&lt;br /&gt;
* mkdir $HOME/online&lt;br /&gt;
* cd $HOME/online&lt;br /&gt;
* create directories for local programs, sources, elog and history: mkdir bin src elog history&lt;br /&gt;
* create data directory: mkdir -p /ladd/data1/t2kvme5/data; ln -s /ladd/data1/t2kvme5/data $HOME/online&lt;br /&gt;
* create the exptab file &amp;quot;$HOME/online/exptab&amp;quot; following the example below. The first entry (exptname) is the name if the DAQ system (MIDAS experiment name), the second entry (/home/USER/online) is the location of MIDAS shared memory buffers (by convention, $HOME/online), the third entry (kopio03) is your username.&lt;br /&gt;
&amp;lt;pre&amp;gt;exptname /home/kopio03/online kopio03&amp;lt;/pre&amp;gt;&lt;br /&gt;
* logout and login again for all changes to take effect&lt;br /&gt;
&lt;br /&gt;
== Setup experiment startup scripts ==&lt;br /&gt;
* login to the experiment host computer&lt;br /&gt;
* echo $MIDAS_SERVER_HOST ### to check correct value - should be blank&lt;br /&gt;
* create $HOME/online/bin/start_daq.sh, replacing XXX with the hostname of the machine running the experiment (and changing the mserver and mhttpd ports, as needed).&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 # start_daq.sh&lt;br /&gt;
 cd $HOME/online&lt;br /&gt;
 #&lt;br /&gt;
 case `hostname` in XXX*)&lt;br /&gt;
    echo &amp;quot;Good, we are on XXX!&amp;quot;&lt;br /&gt;
    ;;&lt;br /&gt;
 *)&lt;br /&gt;
    echo &amp;quot;The start_daq script should be executed on XXX&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
    ;;&lt;br /&gt;
 esac&lt;br /&gt;
 #&lt;br /&gt;
 odbedit -c clean&lt;br /&gt;
 #   start [[mhttpd]] on default port. (Mongoose https version - see [[mhttpd]] for other options)&lt;br /&gt;
 mhttpd  -D  -a localhost -a XXX.triumf.ca # optionally restrict access to specified hosts&lt;br /&gt;
 #&lt;br /&gt;
 #   start [[mserver]] on default port (use argument -p to use a different port) &lt;br /&gt;
 mserver -D   # access must now be specifically allowed - see [[#Setup the experiment environment|above]]&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;&lt;br /&gt;
 # OR ([[#NOTES|older MIDAS versions]])&lt;br /&gt;
 # mhttpd  -p 8081 -D -a localhost -a XXX.triumf.ca      # optionally restrict access to specified hosts&lt;br /&gt;
 # mserver -p 7071 -D -a localhost -a lxdragon01.triumf.ca -a lxdragon02.triumf.ca -a XXX.triumf.ca # optionally restrict access to specified hosts&lt;br /&gt;
 &amp;lt;/span&amp;gt;&lt;br /&gt;
 #&lt;br /&gt;
 mlogger -D&lt;br /&gt;
 #end file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Run the MIDAS Web Server ==&lt;br /&gt;
Let&#039;s start the MIDAS webserver for the first time:&lt;br /&gt;
&lt;br /&gt;
Start [[mhttpd]] on the &#039;&#039;experiment host&#039;&#039; (localhost) like this:&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&amp;lt;/small&amp;gt;&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhttpd,INFO] ODB subtree /Runinfo corrected successfully&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17892:mongoose,ERROR] cannot find SSL certificate file &amp;quot;/home/agdaq/online/ssl_cert.pem&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17893:mongoose,ERROR] please create SSL certificate file: openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key; openssl x509 -req -days 365 -sha256 -in ssl_cert.csr -signkey ssl_cert.key -out ssl_cert.pem; cat ssl_cert.key &amp;gt;&amp;gt; ssl_cert.pem&lt;br /&gt;
 could not start the mongoose web server, see messages and midas.log, bye!&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a self-signed certificate suitable for initial testing by executing the command printed by mhttpd:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 [mhostpc] openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key; openssl x509 -req -days 365 -sha256 -in ssl_cert.csr -signkey ssl_cert.key -out ssl_cert.pem; cat ssl_cert.key &amp;gt;&amp;gt; ssl_cert.pem&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For production use, you should create a properly signed certificate, see [[Mhttpd#Create an SSL certificate|create your own SSL certificate]] or you should run mhttpd behind an SSL proxy.&lt;br /&gt;
&lt;br /&gt;
Run mhttpd again.&lt;br /&gt;
&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhttpd,INFO] ODB subtree /Runinfo corrected successfully&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot;&lt;br /&gt;
 Mongoose web server will use SSL certificate file &amp;quot;/home/johnfoo/packages/midas/ssl_cert.pem&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17633:mongoose,ERROR] mongoose web server cannot find password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17634:mongoose,ERROR] please create password file: htdigest -c /home/johnfoo/online/htpasswd.txt Default midas&lt;br /&gt;
 could not start the mongoose web server, see messages and midas.log, bye!&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the password file by following the instructions printed by mhttpd. The http digest domain name is the experiment name, suggested default user name is &amp;quot;midas&amp;quot;. You will be asked to type in a password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 [mhostpc] htdigest -c /home/johnfoo/online/htpasswd.txt exptname midas&lt;br /&gt;
 Adding password for midas in realm exptname.&lt;br /&gt;
 New password:&lt;br /&gt;
 Re-type new password:&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
It is a good idea to set the password file {{Filepath|path=htpasswd.txt}} readable and writable by owner only.&lt;br /&gt;
&lt;br /&gt;
Now restart  {{Utility|name=mhttpd}}&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot; **see note&lt;br /&gt;
 Mongoose web server will use SSL certificate file &amp;quot;/home/suz/packages/midas/ssl_cert.pem&amp;quot;&lt;br /&gt;
 Mongoose web server will use authentication realm &amp;quot;Default&amp;quot;, password file &amp;quot;./htpasswd.txt&amp;quot;&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Now point a web browser running on the same host computer (localhost) to https://localhost:8443&lt;br /&gt;
If the web browser is running on a different computer, go to URL of the form&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 https://mhostpc.triumf.ca:8443  (substitute your host machine name and domain for &amp;quot;mhostpc.triumf.ca&amp;quot;)&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
If you are using the default SSL certificate you will probably get a message: &amp;quot;This Connection is Untrusted&amp;quot;.  Click &amp;quot;I understand the risks&amp;quot; and add an exception. This is because the test certificate is self-signed. Then confirm an exception. &lt;br /&gt;
&lt;br /&gt;
If instead you get a &amp;quot;connection refused&amp;quot; error, the midas host pc may have the firewall enabled. To make a firewall exception for MIDAS, follow instructions here http://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
&lt;br /&gt;
You should then see an authentication box asking you for the user name and password. The user name is &amp;quot;midas&amp;quot;. Enter the password you just created. The Midas [[Status Page]] should appear with multiple buttons for run control as well as equipment listing (no equipments will be listed as yet) and application listings. Please refer to [[mhttpd]] (the MIDAS Web-based Run Control utility) for further information. You can start and stop runs from the main status page, and use the [[ODB Page]] to access the database (ODB).&lt;br /&gt;
&lt;br /&gt;
; Note &lt;br /&gt;
: Default ports of 8080 and 8443 are used by [[mhttpd]]. If these ports are in use on your machine, start &amp;lt;span style=&amp;quot;color:darkcyan;font-style:italic&amp;quot;&amp;gt;mhttpd&amp;lt;/span&amp;gt; with alternative ports, e.g.&lt;br /&gt;
       &amp;lt;small&amp;gt;[mhostpc] mhttpd --https 8448 --http 8089&amp;lt;/small&amp;gt;&lt;br /&gt;
: or see [[Mhttpd#Usage]] to change the default ports.&lt;br /&gt;
&lt;br /&gt;
== Setup experiment database (ODB) ==&lt;br /&gt;
&lt;br /&gt;
* run $HOME/online/bin/start_daq.sh&lt;br /&gt;
&lt;br /&gt;
* odbedit, run these commands: (replace user names and directory names)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# set &amp;quot;/Logger/Message file&amp;quot; &amp;quot;/home/kopio03/online/midas.log&amp;quot; # obsolete&lt;br /&gt;
set &amp;quot;/Logger/Data Dir&amp;quot;     &amp;quot;/home/kopio03/online/data&amp;quot;&lt;br /&gt;
create STRING &amp;quot;/Logger/History dir&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/History dir&amp;quot;  &amp;quot;/home/kopio03/online/history&amp;quot;&lt;br /&gt;
create STRING &amp;quot;/Logger/Elog dir&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Elog dir&amp;quot;     &amp;quot;/home/kopio03/online/elog&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/ODB dump file&amp;quot; &amp;quot;/home/kopio03/online/history/run%05d.xml&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/ODB dump&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Filename&amp;quot; &amp;quot;run%05dsub%03d.mid.gz&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Subrun byte limit&amp;quot; &amp;quot;1000000000&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Compression&amp;quot;   1&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/ODB Dump&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/Logger/Required&amp;quot; y&lt;br /&gt;
set &amp;quot;/Programs/Logger/Start command&amp;quot; &amp;quot;mlogger -D&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/fevme/Required&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/fevme/Start command&amp;quot; &amp;quot;ssh -n lxdaq09 $HOME/online/src/fevme_gef.exe -O&amp;quot;&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* open web browser e.g. firefox.&lt;br /&gt;
* go to the midas status page at https://localhost:8443  (default port). &lt;br /&gt;
** if running [[mhttpd]] with Mongoose HTTPS/OpenSSL (the default) for the first time, you will need to create a password file. Follow the instructions (see [[mhttpd#HTTPS/SSL server (Mongoose)]] for details).&lt;br /&gt;
** For other options (i.e. HTTPS/SSL proxy) see [[#Secure MIDAS and ELOG Web access]] &lt;br /&gt;
*&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;OR open the midas status page at http://localhost:8081 ([[#NOTES|older MIDAS versions]])&lt;br /&gt;
* midas status page will show most stuff &amp;quot;red&amp;quot; as nothing is running yet&lt;br /&gt;
* DON&#039;T DO THIS YET run ./fevme.exe (on the computer with the VME interface, could be different from computer hosting the experiment), observe that corresponding equipments have been created&lt;br /&gt;
* save the url bookmark to the &amp;quot;personal toolbar&amp;quot;&lt;br /&gt;
* go to the Programs page, stop mlogger, stop fevme, start mlogger, start fevme&lt;br /&gt;
* go to the Status page, start run, stop run&lt;br /&gt;
* go back to the Status page, everything should be green&lt;br /&gt;
* start a run&lt;br /&gt;
* send signals to the ADC gate&lt;br /&gt;
* you should be getting events&lt;br /&gt;
* to look at data, proceed with setting up the [[ROOTANA|ROOT Analyzer]].&lt;br /&gt;
&lt;br /&gt;
== Start DAQ programs at boot time ==&lt;br /&gt;
&lt;br /&gt;
* add this to /etc/rc.local (replace username and location of the start_daq script)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
su - alpha -c /home/alpha/online/bin/start_daq.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setup local software version control ==&lt;br /&gt;
&lt;br /&gt;
Version control for experiment source code is setup using &amp;quot;git&amp;quot; (http://git-scm.com/)&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/online&lt;br /&gt;
* git init&lt;br /&gt;
* git add exptab&lt;br /&gt;
* git add bin/start_daq.sh&lt;br /&gt;
* git add .gitignore ### contents can be&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
*~&lt;br /&gt;
*.o&lt;br /&gt;
*.exe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* git add src/Makefile src/*.cxx ...&lt;br /&gt;
* git commit -a&lt;br /&gt;
&lt;br /&gt;
== Adjust MIDAS buffer sizes ==&lt;br /&gt;
&lt;br /&gt;
Default MIDAS SYSTEM buffer size is 8 Mbytes, fairly small for high-data-rate experiments. The rule of thumb is to have at least a few seconds worth of buffer space available. For example, if event size is 10 Kbytes and the event rate is 1 kHz, data rate is 10*10^3*1*10^3 = 10 Mbytes/sec. To buffer 10 seconds of data we need 100 Mbytes of buffer space.&lt;br /&gt;
&lt;br /&gt;
To resize the MIDAS event buffers (SYSTEM, etc) do this:&lt;br /&gt;
* stop all frontends, stop mlogger&lt;br /&gt;
* start odbedit:&lt;br /&gt;
** cd &amp;quot;/Experiment/Buffer sizes&amp;quot;&lt;br /&gt;
** set SYSTEM 100000000&lt;br /&gt;
* run &amp;quot;mdump -z SYSTEM&amp;quot;&lt;br /&gt;
* if mdump complains about the size of .SYSTEM.SHM, remove it, try again.&lt;br /&gt;
* ls -l /dev/shm ### to observe that the size of shared memory is correct&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Secure MIDAS and ELOG Web access  ==&lt;br /&gt;
In versions prior to May 2015, the default web access to MIDAS and ELOG uses the &amp;quot;http:&amp;quot; protocol which is insecure. In this case, all information is transmitted as clear text meaning that secret, confidential and sensitive information (such as the MIDAS and ELOG passwords and usernames) can be stolen &amp;quot;easily&amp;quot;. This means that even &amp;quot;password protected&amp;quot; MIDAS and ELOG pages are not really protected if accessed using the &amp;quot;http&amp;quot; method. &lt;br /&gt;
 &lt;br /&gt;
Better security for HTTP is gained by using a password protected &#039;&#039;&#039;SSL (https) proxy&#039;&#039;&#039;. (It does not provide absolute security because of remaining problems with the security of SSL certificates, security of passwords, etc). Setting up an SSL (https) proxy is described [[#Setting up an HTTP proxy|below]].&lt;br /&gt;
&lt;br /&gt;
Since May 2015, an &#039;&#039;alternative secure option&#039;&#039; to setting up an HTTP proxy is available to users of MIDAS. Recent versions of elogd (ELOG) do support SSL https:// connections, and [[#mhttpd with HTTPS/SSL server (Mongoose)]] is now available.  This option is the default, and provides a similar level of security to an HTTP proxy. &lt;br /&gt;
&lt;br /&gt;
See [[Security#Web Access]] for a comparison of these two secure options.&lt;br /&gt;
  &lt;br /&gt;
=== mhttpd with HTTPS/SSL server (Mongoose) ===&lt;br /&gt;
&lt;br /&gt;
Since May 2015 the MIDAS web server [[mhttpd]] is explicitly linked with OpenSSL to provide secure HTTPS connections via the [https://bitbucket.org/tmidas/midas/src/ecb9a8537448a8a43f7f9a2bfdb82e578208cde3/doc/mongoose/?at=develop Mongoose] web server (see [[mhttpd]]). With this version, default web access to MIDAS uses the &amp;quot;https&amp;quot; protocol. Web access to {{Utility|name=mhttpd}} can be restricted by using the  &amp;quot;-a hostname&amp;quot; switch of [[mhttpd]]. The first time {{Utility|name=mhttpd}} is run, a password file must be created. An SSL certificate is also required. See [[mhttpd#HTTPS/SSL server (Mongoose)|HTTPS/SSL server (Mongoose)]] for instructions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== mhttpd using an HTTPS/SSL proxy ===&lt;br /&gt;
&lt;br /&gt;
THESE INSTRUCTIONS ARE WRONG, DO NOT DO THIS. See instead [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MIDAS_experiment_at_TRIUMF#Install_https_proxy this section].&lt;br /&gt;
&lt;br /&gt;
An [[#Setting up an HTTP proxy|HTTP proxy]] must be set up. This is the only way of securing older version of [[mhttpd]] (pre August 2015). Older versions of mhttpd are started using the -p port option  e.g.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt; mhttpd  -D -p 8080  &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run a new version of mhttpd using an HTTP proxy, use the options provided to run the old (non-Mongoose) webserver on a given port, i.e.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;  mhttpd --oldserver 8080 --nomg   -D  &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using an SSL proxy, only access from the SSL proxy (and maybe some special trusted machines) should be permitted. &lt;br /&gt;
This is done using the &amp;quot;-a hostname&amp;quot; switch of [[mhttpd]]. Normally there will be only &amp;quot;-a localhost&amp;quot; switch, enabling access only for the local machine (where the SSL proxy is running). Additional &amp;quot;-a hostname&amp;quot; switches enable access from listed local machines. No &amp;quot;-a xxx&amp;quot; enables access from everywhere (defeating the purpose of the SSL proxy, unless access controls are enforced elsewhere, i.e. by a site firewall or by local firewall rules).&lt;br /&gt;
&lt;br /&gt;
== Setting up an HTTP proxy ==&lt;br /&gt;
In this example, we use APACHE HTTPD to password-protect a typical midas/mhttpd and elog installation.&lt;br /&gt;
&lt;br /&gt;
In this configuration, one uses the Linux stock httpd that accepts encrypted https:// connections and forwards them to mhttpd and elogd. Instead of (or in addition to) using mhttpd and elogd passwords, one configures password protection in httpd via the regular apache httpd password mechanisms (htpasswd, etc).&lt;br /&gt;
&lt;br /&gt;
Recent versions of elogd do support SSL https:// connections, but if one is running an SSL proxy for anyway, it is simpler to run both through the same SSL proxy using the same SSL host certificate and the same httpd password file.&lt;br /&gt;
&lt;br /&gt;
=== Restricting http: access to elogd ===&lt;br /&gt;
;Note&lt;br /&gt;
:Recent versions of elogd do support SSL https:// connections. The following information is for those using an HTTP proxy (see above).&lt;br /&gt;
&lt;br /&gt;
For elogd, this is done using the &amp;quot;-n localhost&amp;quot; switch with enables only access from the same machine if present, or access from anywhere is absent (defeating the purpose of the SSL proxy, unless access controls are enforced elsewhere).&lt;br /&gt;
&lt;br /&gt;
(It is recommended to run elogd from the same user as the main daq user and to keep elogd.cfg and all logbooks in the home directory of this user, where they are captured by the normal site backup system)&lt;br /&gt;
&lt;br /&gt;
== Install standalone elog ==&lt;br /&gt;
&lt;br /&gt;
* login into the user account that will run the elog&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/ritt/elog&lt;br /&gt;
* cd elog&lt;br /&gt;
* make&lt;br /&gt;
* create new file start_elogd with this contents:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
killall elogd&lt;br /&gt;
sleep 1&lt;br /&gt;
killall -KILL elogd&lt;br /&gt;
sleep 1&lt;br /&gt;
$HOME/packages/elog/elogd -n localhost -x -c $HOME/packages/elog/elogd.cfg -p 8082 -D&lt;br /&gt;
&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* chmod a+x start_elogd&lt;br /&gt;
* edit elogd.cfg to read:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[global]&lt;br /&gt;
port = 8082&lt;br /&gt;
SMTP host = smtp.triumf.ca&lt;br /&gt;
URL = https://titan00.triumf.ca/elog/&lt;br /&gt;
&lt;br /&gt;
Reverse sort = 1&lt;br /&gt;
Display Mode = full&lt;br /&gt;
&lt;br /&gt;
#List Menu commands = New, Find, Admin, Help&lt;br /&gt;
#Menu commands = New, Edit, Reply, Find, Duplicate, Help&lt;br /&gt;
&lt;br /&gt;
Entries Per Page = 30&lt;br /&gt;
Supress Email on edit = 1&lt;br /&gt;
Default encoding = 1&lt;br /&gt;
Page title = TITAN ELOG&lt;br /&gt;
Resolve host names = 1&lt;br /&gt;
&lt;br /&gt;
Logfile = /home/titan/packages/elog/elogd.log&lt;br /&gt;
#Logging level = 3&lt;br /&gt;
&lt;br /&gt;
[midas]&lt;br /&gt;
&lt;br /&gt;
List page Title = T2K M11 MIDAS ELOG&lt;br /&gt;
Comment = T2K M11 MIDAS ELOG&lt;br /&gt;
Page Title = T2K M11 MIDAS ELOG&lt;br /&gt;
RSS Title = [$logbook - $type - $system] $subject, posted by $author&lt;br /&gt;
&lt;br /&gt;
Attributes = Author, Subject, Run, Type, System&lt;br /&gt;
Show Attributes Edit = Run, Author, Subject, Type, System&lt;br /&gt;
Required Attributes = Author, Type, System, Subject&lt;br /&gt;
&lt;br /&gt;
Options Type = Routine, Reply, Shift Summary, Modification, Question, Info, Problem&lt;br /&gt;
Options System = General, DAQ, Beamline&lt;br /&gt;
&lt;br /&gt;
Preset Run = $shell(MIDASSYS=. /home/t2km11/packages/midas/linux/bin/odbedit -d Runinfo -c &#039;ls -v \&amp;quot;run number\&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
Preset On Reply Type = Reply&lt;br /&gt;
Preset On Reply Run = $shell(MIDASSYS=. /home/t2km11/packages/midas/linux/bin/odbedit -d Runinfo -c &#039;ls -v \&amp;quot;run number\&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
List Display = Date, Subject, Type, System, Author, ID&lt;br /&gt;
Quick Filter = Date, Type, ID&lt;br /&gt;
&lt;br /&gt;
Remove on reply = Author&lt;br /&gt;
Quote on reply = 1&lt;br /&gt;
&lt;br /&gt;
Use lock = 1&lt;br /&gt;
&lt;br /&gt;
************* Email Functionality ****************&lt;br /&gt;
&lt;br /&gt;
Use Email Subject = [T2KM11 - $System] $Subject&lt;br /&gt;
Omit Email To = 1&lt;br /&gt;
&lt;br /&gt;
Email System General = xxx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* ./start_elogd &amp;amp;&lt;br /&gt;
* firefox http://localhost:8082 # hould show the elog message index&lt;br /&gt;
&lt;br /&gt;
To start elogd automatically when the machine is rebooted, login as root and&lt;br /&gt;
* add this text to /etc/rc.local:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
su - titan -c &amp;quot;/home/titan/packages/elog/start_elogd&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* chmod a+x /etc/rc.local&lt;br /&gt;
* systemctl start rc-local&lt;br /&gt;
&lt;br /&gt;
To import elog entries from the mhttpd elog, do this:&lt;br /&gt;
&lt;br /&gt;
* cd ~/packages/elog/logbooks&lt;br /&gt;
* ln -s /home/t2km11/online/elog midas&lt;br /&gt;
* cd midas&lt;br /&gt;
* ~/packages/elog/elconv)&lt;br /&gt;
&lt;br /&gt;
== Install https proxy ==&lt;br /&gt;
&lt;br /&gt;
THESE INSTRUCTIONS ARE OBSOLETE, INSTEAD, &lt;br /&gt;
* GO HERE: https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog&lt;br /&gt;
* AND GO HERE: https://midas.triumf.ca/MidasWiki/index.php/Quickstart_Linux#Run_the_MIDAS_Web_Server&lt;br /&gt;
&lt;br /&gt;
FOLLOWING INSTRUCTIONS ARE OBSOLETE...&lt;br /&gt;
&lt;br /&gt;
* login as root to the https proxy machine&lt;br /&gt;
* cd ~root&lt;br /&gt;
* yum install mod_ssl&lt;br /&gt;
* yum install crypto-utils # see http://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_monitoring_of_HTTPS_certificates&lt;br /&gt;
* create a certificate request (replace ladd09 with your hostname): openssl req -new -nodes -newkey rsa:2048 -sha256 -out ladd09.csr -keyout ladd09.key (answer: CA, BC, Vancouver, TRIUMF, DAQ, ladd09.triumf.ca, email@email.com&lt;br /&gt;
* sign it by TRIUMF:&lt;br /&gt;
** mail -s &amp;quot;Certificate request&amp;quot; yourself@email.com &amp;amp;lt; ladd09.csr&lt;br /&gt;
** forward this request to Andrew Daviel&lt;br /&gt;
** he will email the signed crt file, copy it to this system as ladd09.crt&lt;br /&gt;
* sign it yourself: openssl x509 -req -days 365 -sha256 -in ladd09.csr -signkey ladd09.key -out ladd09.crt&lt;br /&gt;
* (if the certificate expires, renew it by signing it again)&lt;br /&gt;
* Additional commands for working with certificates:&lt;br /&gt;
** explore the private key: openssl pkey -in ladd09.key -text -noout&lt;br /&gt;
** explore the certificate request: openssl req -in ladd00.csr -text -noout&lt;br /&gt;
** explore the certificate: openssl x509 -in ladd09.crt -noout -text&lt;br /&gt;
* move certificate files to proper system locations:&lt;br /&gt;
* mv ladd09.key  /etc/pki/tls/private/&lt;br /&gt;
* mv ladd09.crt /etc/pki/tls/certs/&lt;br /&gt;
* if selinux is enabled, do this:&lt;br /&gt;
** restorecon -Rv /etc/pki/tls/certs/&lt;br /&gt;
** restorecon -Rv /etc/pki/tls/private/&lt;br /&gt;
** /usr/sbin/setsebool -P httpd_can_network_connect 1&lt;br /&gt;
* open /etc/httpd/conf.d/ssl.conf in a text editor, go to the very bottom and right before the &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; entry, add following text:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SSLCertificateFile /etc/pki/tls/certs/ladd09.crt &lt;br /&gt;
SSLCertificateKeyFile /etc/pki/tls/private/ladd09.key &lt;br /&gt;
&lt;br /&gt;
ProxyPass /elog/ http://localhost:8082/ retry=1&lt;br /&gt;
ProxyPass /      http://localhost:8080/ retry=1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Location /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SSLRequireSSL&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthName &amp;quot;password protected site&amp;quot;&lt;br /&gt;
Require valid-user&lt;br /&gt;
&lt;br /&gt;
# create password file: touch /etc/httpd/htpasswd&lt;br /&gt;
# to add new user or change password: htpasswd /etc/httpd/htpasswd username&lt;br /&gt;
AuthUserFile /etc/httpd/htpasswd&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/Location&amp;gt;&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* comment out duplicate &amp;quot;SSLCertificateFile&amp;quot; and &amp;quot;SSLCertificateKeyFile&amp;quot; elsewhere in the file&lt;br /&gt;
* (optionally) If you got a certificate that is signed by DigiCert or RapidSSL then you&#039;ll need to add a line specifying the certificate chain file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SSLCertificateChainFile /etc/pki/tls/certs/DigiCertCA.crt&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* touch /etc/httpd/htpasswd&lt;br /&gt;
* htpasswd /etc/httpd/htpasswd midas # enter password midas&lt;br /&gt;
* chkconfig httpd on&lt;br /&gt;
* service httpd restart&lt;br /&gt;
* firewall-cmd --add-port=443/tcp --permanent&lt;br /&gt;
* firewall-cmd --reload&lt;br /&gt;
* firewall-cmd --list-all&lt;br /&gt;
* test it&lt;br /&gt;
** test the SSL proxy: https://host/ should yield the midas status page, https://host/elog/ should yield the elog message index&lt;br /&gt;
* in ODB, set &amp;quot;/Elog/URL&amp;quot; to &amp;quot;https://host/elog/&amp;quot;&lt;br /&gt;
* now from the midas status page, the &amp;quot;Elog&amp;quot; button should take us to the https Elog URL&lt;br /&gt;
&lt;br /&gt;
In needed, enable user directories: https://blah/~user in ~user/public_html&lt;br /&gt;
&lt;br /&gt;
* edit /etc/httpd/conf.d/userdir.conf, replace &amp;quot;UserDir disabled&amp;quot; with &amp;quot;UserDir enabled&amp;quot;&lt;br /&gt;
* setsebool -P httpd_enable_homedirs true&lt;br /&gt;
* systemctl restart httpd&lt;br /&gt;
&lt;br /&gt;
== Setup the history mhttpd for faster access to history plots ==&lt;br /&gt;
When running an SSL proxy,&lt;br /&gt;
* start the main mhttpd (&amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;orange&amp;lt;/span&amp;gt; command for old mhttpd, &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;green&amp;lt;/span&amp;gt; for new mhttpd with Mongoose(post August2015):&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8071 -D&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D --oldserver 8071 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* start the history mhttpd&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt; &amp;quot;mhttpd -p 8072 -D -H&amp;quot;&amp;lt;/span&amp;gt; or&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D -H --oldserver 8072 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
* set ODB /History/URL to &amp;quot;http://alphacpc09.cern.ch:8072/HS/&amp;quot;&lt;br /&gt;
* open the MIDAS status page&lt;br /&gt;
* go to the history section, try to open any history plot, observe that the history plot gif image loads correctly, inspect it&#039;s URL (use &amp;quot;copy image URL&amp;quot; or &amp;quot;view source&amp;quot;, etc), it should point to port 8072 causing connection to the history mhttpd.&lt;br /&gt;
* continue with these instructions to setup history mhttpd access through an SSL proxy:&lt;br /&gt;
* setup SSL proxy access (required mod_proxy_html)&lt;br /&gt;
** login as root to the SSL proxy machine&lt;br /&gt;
** on SL5, install the missing mod_proxy_html httpd module:&lt;br /&gt;
** yum install httpd-devel libxml2-devel&lt;br /&gt;
** wget http://apache.webthing.com/mod_proxy_html/mod_proxy_html.tar.bz2&lt;br /&gt;
** tar xjvf mod_proxy_html.tar.bz2 &lt;br /&gt;
** cd mod_proxy_html&lt;br /&gt;
** apxs -c -I. -I/usr/include/libxml2 -i mod_proxy_html.c &lt;br /&gt;
** apxs -c -I. -I/usr/include/libxml2 -i mod_xml2enc.c&lt;br /&gt;
** cd /etc/httpd/conf.d, add this to ssl.conf:&lt;br /&gt;
&lt;br /&gt;
;before the ProxyPass statements:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# proxy the MIDAS web servers  &lt;br /&gt;
LoadModule  xml2enc_module       modules/mod_xml2enc.so  &lt;br /&gt;
LoadModule  proxy_html_module    modules/mod_proxy_html.so  &lt;br /&gt;
ProxyHTMLLinks  a               href  &lt;br /&gt;
ProxyHTMLLinks  link            href  &lt;br /&gt;
ProxyHTMLLinks  img             src  &lt;br /&gt;
#ProxyHTMLEnable On  &lt;br /&gt;
ProxyRequests off  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
;after the ProxyPass statements:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ALPHA1 history access &lt;br /&gt;
ProxyPass /alpha1/history/   http://alphacpc09.cern.ch:8072/HS/  retry=1 &lt;br /&gt;
ProxyPass /alpha1/           http://alphacpc09.cern.ch:8071/     retry=1 &lt;br /&gt;
 &lt;br /&gt;
ProxyHTMLEnable On  &lt;br /&gt;
ProxyHTMLURLMap http://alphacpc09.cern.ch:8072/HS/ /alpha1/history/ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
;adjust:&lt;br /&gt;
*&amp;quot;alpha1&amp;quot; is the experiment name&lt;br /&gt;
*&amp;quot;alphacpc09.cern.ch&amp;quot; is the machine running mhttpd&lt;br /&gt;
*&amp;quot;8071&amp;quot; is the port number of the main mhttpd &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8071 -D&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D --oldserver 8071 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
* &amp;quot;8072&amp;quot; is the port number of the history mhttpd &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8072 -D -H&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D -H --oldserver 8072 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]] [[Category:Buffer]] [[Category:Driver]]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MIDAS_experiment_at_TRIUMF&amp;diff=3603</id>
		<title>Setup MIDAS experiment at TRIUMF</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MIDAS_experiment_at_TRIUMF&amp;diff=3603"/>
		<updated>2026-02-03T17:32:31Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* mhttpd using an HTTPS/SSL proxy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This page describes setting up a MIDAS experiment at TRIUMF. This information can be adapted for other sites.&lt;br /&gt;
&lt;br /&gt;
== Environment variables ==&lt;br /&gt;
* &#039;&#039;&#039;MIDASSYS&#039;&#039;&#039; Base directory of the MIDAS package, midas and mxml should be at the same level.&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_EXPTAB&#039;&#039;&#039; Experiment definition file&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_SERVER_HOST&#039;&#039;&#039; MIDAS host server name for remote midas connections.&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_EXPT_NAME&#039;&#039;&#039; Experiment name&lt;br /&gt;
&lt;br /&gt;
== Standard layout of MIDAS experiment ==&lt;br /&gt;
The following shows the directory layout of a standard MIDAS experiment: &lt;br /&gt;
&lt;br /&gt;
 /home/exptuser/&lt;br /&gt;
                packages/&lt;br /&gt;
                        root                   &amp;lt;---- ROOT&lt;br /&gt;
                        mxml&lt;br /&gt;
                        mscb&lt;br /&gt;
                        midas/                 &amp;lt;---- MIDAS&lt;br /&gt;
                              linux/{lib,bin}       &amp;lt;---- binaries matching the selected 64-bit/32-bit flavour of ROOT&lt;br /&gt;
                              linux-m32/{lib,bin}   &amp;lt;---- limited function 32-bit binaries for 32-bit frontend machines, build by &amp;quot;make linux32&amp;quot;&lt;br /&gt;
                              linux-m64/{lib,bin}   &amp;lt;---- limited function 64-bit binaries (only needed if ROOT and linux/bin are 32-bit)&lt;br /&gt;
                              linux-arm/{lib,bin}   &amp;lt;---- full function ARM cross-compiled using &amp;quot;make linuxarm&amp;quot;&lt;br /&gt;
                              linux-crosscompile/{lib,bin}  &amp;lt;---- cross-compiled limited function binaries for PPC and ARM frontends (see Makefile)&lt;br /&gt;
                        rootana                &amp;lt;---- ROOT analyzer&lt;br /&gt;
                        roody                  &amp;lt;---- graphical online histogram viewer for MIDAS and ROOTANA&lt;br /&gt;
                 online/&lt;br /&gt;
                        exptab                         &amp;lt;---- experiment definition&lt;br /&gt;
                        {.ODB,.SYSTEM,.SYSMSG,etc}.SHM &amp;lt;---- MIDAS shared memory save files&lt;br /&gt;
                        src                            &amp;lt;---- experiment frontend sources&lt;br /&gt;
                        bin,scripts&lt;br /&gt;
                        elog                           &amp;lt;---- MIDAS elog&lt;br /&gt;
                        history                        &amp;lt;---- MIDAS history&lt;br /&gt;
                        data -&amp;gt; /data/exptname/current &amp;lt;---- symlink to the data directory&lt;br /&gt;
 /data/exptname/current                                &amp;lt;---- experiment data directory with ODB save files and MIDAS .mid/.mid.gz data files&lt;br /&gt;
&lt;br /&gt;
== Prepare computers ==&lt;br /&gt;
&lt;br /&gt;
On some operating systems, several MIDAS functions require administrator access:&lt;br /&gt;
&lt;br /&gt;
* on el7 linux (SL7/CC7/CentOS7/RHEL7) - access to mhttpd port 8443 requires special firewall rules, see here: https://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
* on el7 linux - access to mserver to run frontends and other programs on some other computer requires special firewall rules, see here: https://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
* on el7 linux - on the frontend machines (and other machines that will connect to the mserver, the same firewall rule needs to be created (use the IP address of the machine running the mserver)&lt;br /&gt;
&lt;br /&gt;
== Prepare the user account ==&lt;br /&gt;
&amp;lt;div id=&amp;quot;NOTES&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Setup the user account for running this instance of midas. For machines part of the LADD cluster, follow these  [http://daq-plone.triumf.ca/SM/docs/local/NewLaddUser] instructions.&lt;br /&gt;
* check that the account is using the /bin/bash shell&lt;br /&gt;
* make $HOME/.profile look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/echo You must source&lt;br /&gt;
&lt;br /&gt;
export SVN_EDITOR=&amp;quot;emacs -nw&amp;quot;&lt;br /&gt;
export GIT_EDITOR=&amp;quot;emacs -nw&amp;quot;&lt;br /&gt;
export MIDASSYS=$HOME/packages/midas&lt;br /&gt;
export ROOTANASYS=$HOME/packages/rootana&lt;br /&gt;
export MIDAS_EXPTAB=$HOME/online/exptab&lt;br /&gt;
#&lt;br /&gt;
# setup the MIDAS mserver&lt;br /&gt;
#&lt;br /&gt;
case `hostname` in&lt;br /&gt;
daq07*)&lt;br /&gt;
   unset MIDAS_SERVER_HOST&lt;br /&gt;
   ;;&lt;br /&gt;
*)&lt;br /&gt;
   export MIDAS_SERVER_HOST=daq07.triumf.ca:7070&lt;br /&gt;
   ;;&lt;br /&gt;
esac&lt;br /&gt;
#&lt;br /&gt;
# select 64-bit or 32-bit MIDAS and ROOT&lt;br /&gt;
#&lt;br /&gt;
case `uname -i` in&lt;br /&gt;
i386)&lt;br /&gt;
   source /daq/daqshare/olchansk/root/root_v5.34.01_SL62_32/bin/thisroot.sh&lt;br /&gt;
   export PATH=.:$MIDASSYS/linux-m32/bin:$PATH&lt;br /&gt;
   ;;&lt;br /&gt;
*)&lt;br /&gt;
   #source /daq/daqshare/olchansk/root/root_v5.34.34_SL67_64/bin/thisroot.sh&lt;br /&gt;
   source $HOME/packages/root/bin/thisroot.sh&lt;br /&gt;
   export PATH=.:$MIDASSYS/linux/bin:$PATH&lt;br /&gt;
   ;;&lt;br /&gt;
esac&lt;br /&gt;
#&lt;br /&gt;
export PATH=.:$HOME/online/bin:$HOME/packages/roody/bin:$PATH&lt;br /&gt;
#&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* mkdir $HOME/packages&lt;br /&gt;
* Logout and login again, for .cshrc changes to take effect&lt;br /&gt;
&lt;br /&gt;
== Install ROOT ==&lt;br /&gt;
&lt;br /&gt;
* Identify the Linux version: RH9 (Red Hat Linux 9), FC3 (Fedora Core 3), RHEL4/SL4 (Red Hat Enterprise LInux 4/Scientific Linux 4), SL5x, SL6x, (CentOS/CC/SL) el7x: more /etc/redhat-release&lt;br /&gt;
* Decide to use 32-bit or 64-bit ROOT (&#039;uname -a&#039;)&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* ls -l /daq/daqshare/olchansk/root/ ### to see all available ROOT packages&lt;br /&gt;
* ln -s /daq/daqshare/olchansk/root/root_vNNN_VVV_BB root, where NNN is the latest available version of ROOT (&amp;quot;ls -l /daq/daqshare/olchansk/root&amp;quot;), VVV is the Linux version code (RH9, FC3, SL4, etc) and BB is &amp;quot;_32&amp;quot; or &amp;quot;_64&amp;quot; for 32-bit or 64-bit ROOT. For example: /daq/daqshare/olchansk/root/root_v5.10.00_SL40&lt;br /&gt;
* for example: ln -s /daq/daqshare/olchansk/root/root_v5.34.34_el72_64 $HOME/packages/root&lt;br /&gt;
* Check that ROOT works: &amp;quot;source $HOME/packages/root/bin/thisroot.sh; root&amp;quot;. Type &amp;quot;.q&amp;quot; to exit root.&lt;br /&gt;
&lt;br /&gt;
== Install MIDAS ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* (OBSOLETE) svn co svn+ssh://svn@savannah.psi.ch/repos/meg/midas/trunk midas, password &amp;quot;svn&amp;quot;. (password has to be entered twice)&lt;br /&gt;
* (OBSOLETE) svn co svn+ssh://svn@savannah.psi.ch/repos/meg/mxml/trunk mxml&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/midas --recursive&lt;br /&gt;
* (OBSOLETE) git clone https://bitbucket.org/tmidas/mxml&lt;br /&gt;
* (OBSOLETE) git clone https://bitbucket.org/tmidas/mscb&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mxml.git&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mscb.git&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/midas.git&lt;br /&gt;
* cd midas&lt;br /&gt;
* make&lt;br /&gt;
* (only if needed) make linux32 ### build the 32-bit MIDAS libraries&lt;br /&gt;
* ls -l linux/bin/odbedit ### check that odbedit has been created (do not run it yet)&lt;br /&gt;
&lt;br /&gt;
You can see a list of other installation problems at [[Common problems &amp;amp; Debugging recipes]].&lt;br /&gt;
&lt;br /&gt;
;NOTE 1&lt;br /&gt;
: Optional features in MIDAS can be explicitly disabled if desired when making MIDAS using the NO_xxx feature (NO_ROOT,NO_MYSQL,NO_ODBC,NO_SQLITE,NO_MSCB), e.g. &amp;quot;make NO_ROOT=1&amp;quot; to disable ROOT. These NO_xxx Makefile variables are only used to control autodetection.&lt;br /&gt;
&lt;br /&gt;
;NOTE 2&lt;br /&gt;
: Since June 2019 the mxml and mscb packages are submodules of the midas package, so no need to clone them separately. If you have an existing clone of midas but not yet the submodules, you need&lt;br /&gt;
&lt;br /&gt;
 $ git submodule update --init --recursive&lt;br /&gt;
&lt;br /&gt;
: To update both midas and the submodules, you need&lt;br /&gt;
&lt;br /&gt;
 $ git pull --recurse-submodules&lt;br /&gt;
&lt;br /&gt;
== Install ROOTANA ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
* cd rootana&lt;br /&gt;
* make&lt;br /&gt;
&lt;br /&gt;
== Install ROODY ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/roody&lt;br /&gt;
* cd roody&lt;br /&gt;
* make&lt;br /&gt;
* $HOME/packages/roody/bin/roody, run the program&lt;br /&gt;
&lt;br /&gt;
== Install additional additional packages ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/ttriumfdaq/vme&lt;br /&gt;
* git clone https://bitbucket.org/ttriumfdaq/frontends&lt;br /&gt;
&lt;br /&gt;
== Build special versions of MIDAS ==&lt;br /&gt;
&lt;br /&gt;
Build special versions of MIDAS for the case when some MIDAS programs, such as VME frontends, will run on a different computer that may have a different flavour of operating system, i.e. 32-bit linux or an older version of Scientific Linux.&lt;br /&gt;
&lt;br /&gt;
* login to the computer where the frontends will run and:&lt;br /&gt;
* if it is a 32-bit linux: cd $HOME/packages/midas; make linux32&lt;br /&gt;
* if it is a 64-bit linux: cd $HOME/packages/midas; make linux64&lt;br /&gt;
&lt;br /&gt;
* login to the host computer to cross-compile ARM code:&lt;br /&gt;
* if it is an ARM linux: cd $HOME/packages/midas; make linuxarm # may need to install ARM cross compilers&lt;br /&gt;
&lt;br /&gt;
== Prepare VME hardware ==&lt;br /&gt;
&lt;br /&gt;
Hardware check list:&lt;br /&gt;
* VME crate&lt;br /&gt;
* VME processor (supported are V77xx, V7805, V7865)&lt;br /&gt;
* On all VME modules, set the VME address jumpers as described here: http://daq-plone.triumf.ca/SM/docs/local/vme_jumpers&lt;br /&gt;
* run vmescan to confirm correct VME addresses&lt;br /&gt;
** cd $HOME/packages&lt;br /&gt;
** svn checkout https://ladd00.triumf.ca/svn/daqsvn/trunk/vme&lt;br /&gt;
** cd vme&lt;br /&gt;
** make&lt;br /&gt;
** ./vmescan.exe (or _gef.exe, depending on the VME driver in use)&lt;br /&gt;
&lt;br /&gt;
== Install Universe-II VME driver (V7648, V7750, V7805, V7851) ==&lt;br /&gt;
&lt;br /&gt;
* login as root (ssh root@localhost)&lt;br /&gt;
* follow instructions: https://www.triumf.info/wiki/DAQwiki/index.php/VME-CPU#V7648.2C_V7750.2C_V7805.2C_V7851_:_Setup_vme_universe_VME_drivers&lt;br /&gt;
* cd ~/packages/vme; vmescan.exe&lt;br /&gt;
&lt;br /&gt;
== Install Tsi-148 VME driver (V7865) ==&lt;br /&gt;
&lt;br /&gt;
* login as root (ssh root@localhost)&lt;br /&gt;
* follow instructions: https://www.triumf.info/wiki/DAQwiki/index.php/VME-CPU#V7865_and_XVB-602_:_Setup_gefvme.2Ftsi148_VME_drivers&lt;br /&gt;
* cd ~/packages/vme; vmescan_gef.exe&lt;br /&gt;
&lt;br /&gt;
== Setup the experiment environment ==&lt;br /&gt;
&lt;br /&gt;
* Decide which computer will host MIDAS (where MIDAS shared memory buffers will reside). &lt;br /&gt;
: This computer will run the [[mserver]], [[mlogger]] and [[mhttpd]] applications. (It is usually the machine where the MIDAS,ROOT etc. packages have been downloaded). It will be referred to as the host machine (localhost).&lt;br /&gt;
&lt;br /&gt;
The environment is slightly different depending on whether all programs run on the host machine, or whether some programs run on remote host(s) : &lt;br /&gt;
=== ALL programs run on localhost ===&lt;br /&gt;
:If all programs run on the host machine (localhost), it is not necessary to run [[mserver]]. [[Environment Variables#MIDAS_SERVER_HOST|MIDAS_SERVER_HOST]] will not be assigned (see example .cshrc [[#Prepare the user account|above]]).&lt;br /&gt;
&lt;br /&gt;
=== Some programs run on REMOTE host(s) ===&lt;br /&gt;
: &#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; &lt;br /&gt;
# Since August 2015 &#039;&#039;&#039;you must explicitly allow access for clients running on remote machines&#039;&#039;&#039;. To do this, follow the &#039;&#039;&#039;[[Security#MIDAS programs on remote machines|instructions here]]&#039;&#039;&#039;.&lt;br /&gt;
# The example code .cshrc ([[#Prepare the user account|see above]]) should be present on both host and remote machine(s). This will ensure that [[Environment Variables#MIDAS_SERVER_HOST|MIDAS_SERVER_HOST]] will NOT be set for the host machine (localhost), but on a remote machine, MIDAS_SERVER_HOST will be set to the MIDAS host machine. &lt;br /&gt;
# The client [[mserver]] must be started on the MIDAS host machine. Note that multiple experiments can run on the same host machine by starting several instances of [[mserver]] (one for each experiment) running with different ports (and .cshrc would be edited so that MIDAS_SERVER_HOST is set to the appropriate port for the experiment).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
On the host machine:&lt;br /&gt;
* mkdir $HOME/online&lt;br /&gt;
* cd $HOME/online&lt;br /&gt;
* create directories for local programs, sources, elog and history: mkdir bin src elog history&lt;br /&gt;
* create data directory: mkdir -p /ladd/data1/t2kvme5/data; ln -s /ladd/data1/t2kvme5/data $HOME/online&lt;br /&gt;
* create the exptab file &amp;quot;$HOME/online/exptab&amp;quot; following the example below. The first entry (exptname) is the name if the DAQ system (MIDAS experiment name), the second entry (/home/USER/online) is the location of MIDAS shared memory buffers (by convention, $HOME/online), the third entry (kopio03) is your username.&lt;br /&gt;
&amp;lt;pre&amp;gt;exptname /home/kopio03/online kopio03&amp;lt;/pre&amp;gt;&lt;br /&gt;
* logout and login again for all changes to take effect&lt;br /&gt;
&lt;br /&gt;
== Setup experiment startup scripts ==&lt;br /&gt;
* login to the experiment host computer&lt;br /&gt;
* echo $MIDAS_SERVER_HOST ### to check correct value - should be blank&lt;br /&gt;
* create $HOME/online/bin/start_daq.sh, replacing XXX with the hostname of the machine running the experiment (and changing the mserver and mhttpd ports, as needed).&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 # start_daq.sh&lt;br /&gt;
 cd $HOME/online&lt;br /&gt;
 #&lt;br /&gt;
 case `hostname` in XXX*)&lt;br /&gt;
    echo &amp;quot;Good, we are on XXX!&amp;quot;&lt;br /&gt;
    ;;&lt;br /&gt;
 *)&lt;br /&gt;
    echo &amp;quot;The start_daq script should be executed on XXX&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
    ;;&lt;br /&gt;
 esac&lt;br /&gt;
 #&lt;br /&gt;
 odbedit -c clean&lt;br /&gt;
 #   start [[mhttpd]] on default port. (Mongoose https version - see [[mhttpd]] for other options)&lt;br /&gt;
 mhttpd  -D  -a localhost -a XXX.triumf.ca # optionally restrict access to specified hosts&lt;br /&gt;
 #&lt;br /&gt;
 #   start [[mserver]] on default port (use argument -p to use a different port) &lt;br /&gt;
 mserver -D   # access must now be specifically allowed - see [[#Setup the experiment environment|above]]&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;&lt;br /&gt;
 # OR ([[#NOTES|older MIDAS versions]])&lt;br /&gt;
 # mhttpd  -p 8081 -D -a localhost -a XXX.triumf.ca      # optionally restrict access to specified hosts&lt;br /&gt;
 # mserver -p 7071 -D -a localhost -a lxdragon01.triumf.ca -a lxdragon02.triumf.ca -a XXX.triumf.ca # optionally restrict access to specified hosts&lt;br /&gt;
 &amp;lt;/span&amp;gt;&lt;br /&gt;
 #&lt;br /&gt;
 mlogger -D&lt;br /&gt;
 #end file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Run the MIDAS Web Server ==&lt;br /&gt;
Let&#039;s start the MIDAS webserver for the first time:&lt;br /&gt;
&lt;br /&gt;
Start [[mhttpd]] on the &#039;&#039;experiment host&#039;&#039; (localhost) like this:&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&amp;lt;/small&amp;gt;&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhttpd,INFO] ODB subtree /Runinfo corrected successfully&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17892:mongoose,ERROR] cannot find SSL certificate file &amp;quot;/home/agdaq/online/ssl_cert.pem&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17893:mongoose,ERROR] please create SSL certificate file: openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key; openssl x509 -req -days 365 -sha256 -in ssl_cert.csr -signkey ssl_cert.key -out ssl_cert.pem; cat ssl_cert.key &amp;gt;&amp;gt; ssl_cert.pem&lt;br /&gt;
 could not start the mongoose web server, see messages and midas.log, bye!&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a self-signed certificate suitable for initial testing by executing the command printed by mhttpd:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 [mhostpc] openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key; openssl x509 -req -days 365 -sha256 -in ssl_cert.csr -signkey ssl_cert.key -out ssl_cert.pem; cat ssl_cert.key &amp;gt;&amp;gt; ssl_cert.pem&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For production use, you should create a properly signed certificate, see [[Mhttpd#Create an SSL certificate|create your own SSL certificate]] or you should run mhttpd behind an SSL proxy.&lt;br /&gt;
&lt;br /&gt;
Run mhttpd again.&lt;br /&gt;
&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhttpd,INFO] ODB subtree /Runinfo corrected successfully&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot;&lt;br /&gt;
 Mongoose web server will use SSL certificate file &amp;quot;/home/johnfoo/packages/midas/ssl_cert.pem&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17633:mongoose,ERROR] mongoose web server cannot find password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17634:mongoose,ERROR] please create password file: htdigest -c /home/johnfoo/online/htpasswd.txt Default midas&lt;br /&gt;
 could not start the mongoose web server, see messages and midas.log, bye!&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the password file by following the instructions printed by mhttpd. The http digest domain name is the experiment name, suggested default user name is &amp;quot;midas&amp;quot;. You will be asked to type in a password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 [mhostpc] htdigest -c /home/johnfoo/online/htpasswd.txt exptname midas&lt;br /&gt;
 Adding password for midas in realm exptname.&lt;br /&gt;
 New password:&lt;br /&gt;
 Re-type new password:&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
It is a good idea to set the password file {{Filepath|path=htpasswd.txt}} readable and writable by owner only.&lt;br /&gt;
&lt;br /&gt;
Now restart  {{Utility|name=mhttpd}}&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot; **see note&lt;br /&gt;
 Mongoose web server will use SSL certificate file &amp;quot;/home/suz/packages/midas/ssl_cert.pem&amp;quot;&lt;br /&gt;
 Mongoose web server will use authentication realm &amp;quot;Default&amp;quot;, password file &amp;quot;./htpasswd.txt&amp;quot;&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Now point a web browser running on the same host computer (localhost) to https://localhost:8443&lt;br /&gt;
If the web browser is running on a different computer, go to URL of the form&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 https://mhostpc.triumf.ca:8443  (substitute your host machine name and domain for &amp;quot;mhostpc.triumf.ca&amp;quot;)&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
If you are using the default SSL certificate you will probably get a message: &amp;quot;This Connection is Untrusted&amp;quot;.  Click &amp;quot;I understand the risks&amp;quot; and add an exception. This is because the test certificate is self-signed. Then confirm an exception. &lt;br /&gt;
&lt;br /&gt;
If instead you get a &amp;quot;connection refused&amp;quot; error, the midas host pc may have the firewall enabled. To make a firewall exception for MIDAS, follow instructions here http://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
&lt;br /&gt;
You should then see an authentication box asking you for the user name and password. The user name is &amp;quot;midas&amp;quot;. Enter the password you just created. The Midas [[Status Page]] should appear with multiple buttons for run control as well as equipment listing (no equipments will be listed as yet) and application listings. Please refer to [[mhttpd]] (the MIDAS Web-based Run Control utility) for further information. You can start and stop runs from the main status page, and use the [[ODB Page]] to access the database (ODB).&lt;br /&gt;
&lt;br /&gt;
; Note &lt;br /&gt;
: Default ports of 8080 and 8443 are used by [[mhttpd]]. If these ports are in use on your machine, start &amp;lt;span style=&amp;quot;color:darkcyan;font-style:italic&amp;quot;&amp;gt;mhttpd&amp;lt;/span&amp;gt; with alternative ports, e.g.&lt;br /&gt;
       &amp;lt;small&amp;gt;[mhostpc] mhttpd --https 8448 --http 8089&amp;lt;/small&amp;gt;&lt;br /&gt;
: or see [[Mhttpd#Usage]] to change the default ports.&lt;br /&gt;
&lt;br /&gt;
== Setup experiment database (ODB) ==&lt;br /&gt;
&lt;br /&gt;
* run $HOME/online/bin/start_daq.sh&lt;br /&gt;
&lt;br /&gt;
* odbedit, run these commands: (replace user names and directory names)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set &amp;quot;/Logger/Message file&amp;quot; &amp;quot;/home/kopio03/online/midas.log&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Data Dir&amp;quot;     &amp;quot;/home/kopio03/online/data&amp;quot;&lt;br /&gt;
create STRING &amp;quot;/Logger/History dir&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/History dir&amp;quot;  &amp;quot;/home/kopio03/online/history&amp;quot;&lt;br /&gt;
create STRING &amp;quot;/Logger/Elog dir&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Elog dir&amp;quot;     &amp;quot;/home/kopio03/online/elog&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/ODB dump file&amp;quot; &amp;quot;/home/kopio03/online/history/run%05d.xml&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/ODB dump&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Filename&amp;quot; &amp;quot;run%05dsub%03d.mid.gz&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Subrun byte limit&amp;quot; &amp;quot;1000000000&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Compression&amp;quot;   1&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/ODB Dump&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/Logger/Required&amp;quot; y&lt;br /&gt;
set &amp;quot;/Programs/Logger/Start command&amp;quot; &amp;quot;mlogger -D&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/fevme/Required&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/fevme/Start command&amp;quot; &amp;quot;ssh -n lxdaq09 $HOME/online/src/fevme_gef.exe -O&amp;quot;&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* open web browser e.g. firefox.&lt;br /&gt;
* go to the midas status page at https://localhost:8443  (default port). &lt;br /&gt;
** if running [[mhttpd]] with Mongoose HTTPS/OpenSSL (the default) for the first time, you will need to create a password file. Follow the instructions (see [[mhttpd#HTTPS/SSL server (Mongoose)]] for details).&lt;br /&gt;
** For other options (i.e. HTTPS/SSL proxy) see [[#Secure MIDAS and ELOG Web access]] &lt;br /&gt;
*&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;OR open the midas status page at http://localhost:8081 ([[#NOTES|older MIDAS versions]])&lt;br /&gt;
* midas status page will show most stuff &amp;quot;red&amp;quot; as nothing is running yet&lt;br /&gt;
* DON&#039;T DO THIS YET run ./fevme.exe (on the computer with the VME interface, could be different from computer hosting the experiment), observe that corresponding equipments have been created&lt;br /&gt;
* save the url bookmark to the &amp;quot;personal toolbar&amp;quot;&lt;br /&gt;
* go to the Programs page, stop mlogger, stop fevme, start mlogger, start fevme&lt;br /&gt;
* go to the Status page, start run, stop run&lt;br /&gt;
* go back to the Status page, everything should be green&lt;br /&gt;
* start a run&lt;br /&gt;
* send signals to the ADC gate&lt;br /&gt;
* you should be getting events&lt;br /&gt;
* to look at data, proceed with setting up the [[ROOTANA|ROOT Analyzer]].&lt;br /&gt;
&lt;br /&gt;
== Start DAQ programs at boot time ==&lt;br /&gt;
&lt;br /&gt;
* add this to /etc/rc.local (replace username and location of the start_daq script)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
su - alpha -c /home/alpha/online/bin/start_daq.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setup local software version control ==&lt;br /&gt;
&lt;br /&gt;
Version control for experiment source code is setup using &amp;quot;git&amp;quot; (http://git-scm.com/)&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/online&lt;br /&gt;
* git init&lt;br /&gt;
* git add exptab&lt;br /&gt;
* git add bin/start_daq.sh&lt;br /&gt;
* git add .gitignore ### contents can be&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
*~&lt;br /&gt;
*.o&lt;br /&gt;
*.exe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* git add src/Makefile src/*.cxx ...&lt;br /&gt;
* git commit -a&lt;br /&gt;
&lt;br /&gt;
== Adjust MIDAS buffer sizes ==&lt;br /&gt;
&lt;br /&gt;
Default MIDAS SYSTEM buffer size is 8 Mbytes, fairly small for high-data-rate experiments. The rule of thumb is to have at least a few seconds worth of buffer space available. For example, if event size is 10 Kbytes and the event rate is 1 kHz, data rate is 10*10^3*1*10^3 = 10 Mbytes/sec. To buffer 10 seconds of data we need 100 Mbytes of buffer space.&lt;br /&gt;
&lt;br /&gt;
To resize the MIDAS event buffers (SYSTEM, etc) do this:&lt;br /&gt;
* stop all frontends, stop mlogger&lt;br /&gt;
* start odbedit:&lt;br /&gt;
** cd &amp;quot;/Experiment/Buffer sizes&amp;quot;&lt;br /&gt;
** set SYSTEM 100000000&lt;br /&gt;
* run &amp;quot;mdump -z SYSTEM&amp;quot;&lt;br /&gt;
* if mdump complains about the size of .SYSTEM.SHM, remove it, try again.&lt;br /&gt;
* ls -l /dev/shm ### to observe that the size of shared memory is correct&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Secure MIDAS and ELOG Web access  ==&lt;br /&gt;
In versions prior to May 2015, the default web access to MIDAS and ELOG uses the &amp;quot;http:&amp;quot; protocol which is insecure. In this case, all information is transmitted as clear text meaning that secret, confidential and sensitive information (such as the MIDAS and ELOG passwords and usernames) can be stolen &amp;quot;easily&amp;quot;. This means that even &amp;quot;password protected&amp;quot; MIDAS and ELOG pages are not really protected if accessed using the &amp;quot;http&amp;quot; method. &lt;br /&gt;
 &lt;br /&gt;
Better security for HTTP is gained by using a password protected &#039;&#039;&#039;SSL (https) proxy&#039;&#039;&#039;. (It does not provide absolute security because of remaining problems with the security of SSL certificates, security of passwords, etc). Setting up an SSL (https) proxy is described [[#Setting up an HTTP proxy|below]].&lt;br /&gt;
&lt;br /&gt;
Since May 2015, an &#039;&#039;alternative secure option&#039;&#039; to setting up an HTTP proxy is available to users of MIDAS. Recent versions of elogd (ELOG) do support SSL https:// connections, and [[#mhttpd with HTTPS/SSL server (Mongoose)]] is now available.  This option is the default, and provides a similar level of security to an HTTP proxy. &lt;br /&gt;
&lt;br /&gt;
See [[Security#Web Access]] for a comparison of these two secure options.&lt;br /&gt;
  &lt;br /&gt;
=== mhttpd with HTTPS/SSL server (Mongoose) ===&lt;br /&gt;
&lt;br /&gt;
Since May 2015 the MIDAS web server [[mhttpd]] is explicitly linked with OpenSSL to provide secure HTTPS connections via the [https://bitbucket.org/tmidas/midas/src/ecb9a8537448a8a43f7f9a2bfdb82e578208cde3/doc/mongoose/?at=develop Mongoose] web server (see [[mhttpd]]). With this version, default web access to MIDAS uses the &amp;quot;https&amp;quot; protocol. Web access to {{Utility|name=mhttpd}} can be restricted by using the  &amp;quot;-a hostname&amp;quot; switch of [[mhttpd]]. The first time {{Utility|name=mhttpd}} is run, a password file must be created. An SSL certificate is also required. See [[mhttpd#HTTPS/SSL server (Mongoose)|HTTPS/SSL server (Mongoose)]] for instructions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== mhttpd using an HTTPS/SSL proxy ===&lt;br /&gt;
&lt;br /&gt;
THESE INSTRUCTIONS ARE WRONG, DO NOT DO THIS. See instead [https://daq00.triumf.ca/MidasWiki/index.php/Setup_MIDAS_experiment_at_TRIUMF#Install_https_proxy this section].&lt;br /&gt;
&lt;br /&gt;
An [[#Setting up an HTTP proxy|HTTP proxy]] must be set up. This is the only way of securing older version of [[mhttpd]] (pre August 2015). Older versions of mhttpd are started using the -p port option  e.g.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt; mhttpd  -D -p 8080  &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run a new version of mhttpd using an HTTP proxy, use the options provided to run the old (non-Mongoose) webserver on a given port, i.e.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;  mhttpd --oldserver 8080 --nomg   -D  &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using an SSL proxy, only access from the SSL proxy (and maybe some special trusted machines) should be permitted. &lt;br /&gt;
This is done using the &amp;quot;-a hostname&amp;quot; switch of [[mhttpd]]. Normally there will be only &amp;quot;-a localhost&amp;quot; switch, enabling access only for the local machine (where the SSL proxy is running). Additional &amp;quot;-a hostname&amp;quot; switches enable access from listed local machines. No &amp;quot;-a xxx&amp;quot; enables access from everywhere (defeating the purpose of the SSL proxy, unless access controls are enforced elsewhere, i.e. by a site firewall or by local firewall rules).&lt;br /&gt;
&lt;br /&gt;
== Setting up an HTTP proxy ==&lt;br /&gt;
In this example, we use APACHE HTTPD to password-protect a typical midas/mhttpd and elog installation.&lt;br /&gt;
&lt;br /&gt;
In this configuration, one uses the Linux stock httpd that accepts encrypted https:// connections and forwards them to mhttpd and elogd. Instead of (or in addition to) using mhttpd and elogd passwords, one configures password protection in httpd via the regular apache httpd password mechanisms (htpasswd, etc).&lt;br /&gt;
&lt;br /&gt;
Recent versions of elogd do support SSL https:// connections, but if one is running an SSL proxy for anyway, it is simpler to run both through the same SSL proxy using the same SSL host certificate and the same httpd password file.&lt;br /&gt;
&lt;br /&gt;
=== Restricting http: access to elogd ===&lt;br /&gt;
;Note&lt;br /&gt;
:Recent versions of elogd do support SSL https:// connections. The following information is for those using an HTTP proxy (see above).&lt;br /&gt;
&lt;br /&gt;
For elogd, this is done using the &amp;quot;-n localhost&amp;quot; switch with enables only access from the same machine if present, or access from anywhere is absent (defeating the purpose of the SSL proxy, unless access controls are enforced elsewhere).&lt;br /&gt;
&lt;br /&gt;
(It is recommended to run elogd from the same user as the main daq user and to keep elogd.cfg and all logbooks in the home directory of this user, where they are captured by the normal site backup system)&lt;br /&gt;
&lt;br /&gt;
== Install standalone elog ==&lt;br /&gt;
&lt;br /&gt;
* login into the user account that will run the elog&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/ritt/elog&lt;br /&gt;
* cd elog&lt;br /&gt;
* make&lt;br /&gt;
* create new file start_elogd with this contents:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
killall elogd&lt;br /&gt;
sleep 1&lt;br /&gt;
killall -KILL elogd&lt;br /&gt;
sleep 1&lt;br /&gt;
$HOME/packages/elog/elogd -n localhost -x -c $HOME/packages/elog/elogd.cfg -p 8082 -D&lt;br /&gt;
&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* chmod a+x start_elogd&lt;br /&gt;
* edit elogd.cfg to read:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[global]&lt;br /&gt;
port = 8082&lt;br /&gt;
SMTP host = smtp.triumf.ca&lt;br /&gt;
URL = https://titan00.triumf.ca/elog/&lt;br /&gt;
&lt;br /&gt;
Reverse sort = 1&lt;br /&gt;
Display Mode = full&lt;br /&gt;
&lt;br /&gt;
#List Menu commands = New, Find, Admin, Help&lt;br /&gt;
#Menu commands = New, Edit, Reply, Find, Duplicate, Help&lt;br /&gt;
&lt;br /&gt;
Entries Per Page = 30&lt;br /&gt;
Supress Email on edit = 1&lt;br /&gt;
Default encoding = 1&lt;br /&gt;
Page title = TITAN ELOG&lt;br /&gt;
Resolve host names = 1&lt;br /&gt;
&lt;br /&gt;
Logfile = /home/titan/packages/elog/elogd.log&lt;br /&gt;
#Logging level = 3&lt;br /&gt;
&lt;br /&gt;
[midas]&lt;br /&gt;
&lt;br /&gt;
List page Title = T2K M11 MIDAS ELOG&lt;br /&gt;
Comment = T2K M11 MIDAS ELOG&lt;br /&gt;
Page Title = T2K M11 MIDAS ELOG&lt;br /&gt;
RSS Title = [$logbook - $type - $system] $subject, posted by $author&lt;br /&gt;
&lt;br /&gt;
Attributes = Author, Subject, Run, Type, System&lt;br /&gt;
Show Attributes Edit = Run, Author, Subject, Type, System&lt;br /&gt;
Required Attributes = Author, Type, System, Subject&lt;br /&gt;
&lt;br /&gt;
Options Type = Routine, Reply, Shift Summary, Modification, Question, Info, Problem&lt;br /&gt;
Options System = General, DAQ, Beamline&lt;br /&gt;
&lt;br /&gt;
Preset Run = $shell(MIDASSYS=. /home/t2km11/packages/midas/linux/bin/odbedit -d Runinfo -c &#039;ls -v \&amp;quot;run number\&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
Preset On Reply Type = Reply&lt;br /&gt;
Preset On Reply Run = $shell(MIDASSYS=. /home/t2km11/packages/midas/linux/bin/odbedit -d Runinfo -c &#039;ls -v \&amp;quot;run number\&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
List Display = Date, Subject, Type, System, Author, ID&lt;br /&gt;
Quick Filter = Date, Type, ID&lt;br /&gt;
&lt;br /&gt;
Remove on reply = Author&lt;br /&gt;
Quote on reply = 1&lt;br /&gt;
&lt;br /&gt;
Use lock = 1&lt;br /&gt;
&lt;br /&gt;
************* Email Functionality ****************&lt;br /&gt;
&lt;br /&gt;
Use Email Subject = [T2KM11 - $System] $Subject&lt;br /&gt;
Omit Email To = 1&lt;br /&gt;
&lt;br /&gt;
Email System General = xxx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* ./start_elogd &amp;amp;&lt;br /&gt;
* firefox http://localhost:8082 # hould show the elog message index&lt;br /&gt;
&lt;br /&gt;
To start elogd automatically when the machine is rebooted, login as root and&lt;br /&gt;
* add this text to /etc/rc.local:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
su - titan -c &amp;quot;/home/titan/packages/elog/start_elogd&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* chmod a+x /etc/rc.local&lt;br /&gt;
* systemctl start rc-local&lt;br /&gt;
&lt;br /&gt;
To import elog entries from the mhttpd elog, do this:&lt;br /&gt;
&lt;br /&gt;
* cd ~/packages/elog/logbooks&lt;br /&gt;
* ln -s /home/t2km11/online/elog midas&lt;br /&gt;
* cd midas&lt;br /&gt;
* ~/packages/elog/elconv)&lt;br /&gt;
&lt;br /&gt;
== Install https proxy ==&lt;br /&gt;
&lt;br /&gt;
THESE INSTRUCTIONS ARE OBSOLETE, INSTEAD, &lt;br /&gt;
* GO HERE: https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog&lt;br /&gt;
* AND GO HERE: https://midas.triumf.ca/MidasWiki/index.php/Quickstart_Linux#Run_the_MIDAS_Web_Server&lt;br /&gt;
&lt;br /&gt;
FOLLOWING INSTRUCTIONS ARE OBSOLETE...&lt;br /&gt;
&lt;br /&gt;
* login as root to the https proxy machine&lt;br /&gt;
* cd ~root&lt;br /&gt;
* yum install mod_ssl&lt;br /&gt;
* yum install crypto-utils # see http://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_monitoring_of_HTTPS_certificates&lt;br /&gt;
* create a certificate request (replace ladd09 with your hostname): openssl req -new -nodes -newkey rsa:2048 -sha256 -out ladd09.csr -keyout ladd09.key (answer: CA, BC, Vancouver, TRIUMF, DAQ, ladd09.triumf.ca, email@email.com&lt;br /&gt;
* sign it by TRIUMF:&lt;br /&gt;
** mail -s &amp;quot;Certificate request&amp;quot; yourself@email.com &amp;amp;lt; ladd09.csr&lt;br /&gt;
** forward this request to Andrew Daviel&lt;br /&gt;
** he will email the signed crt file, copy it to this system as ladd09.crt&lt;br /&gt;
* sign it yourself: openssl x509 -req -days 365 -sha256 -in ladd09.csr -signkey ladd09.key -out ladd09.crt&lt;br /&gt;
* (if the certificate expires, renew it by signing it again)&lt;br /&gt;
* Additional commands for working with certificates:&lt;br /&gt;
** explore the private key: openssl pkey -in ladd09.key -text -noout&lt;br /&gt;
** explore the certificate request: openssl req -in ladd00.csr -text -noout&lt;br /&gt;
** explore the certificate: openssl x509 -in ladd09.crt -noout -text&lt;br /&gt;
* move certificate files to proper system locations:&lt;br /&gt;
* mv ladd09.key  /etc/pki/tls/private/&lt;br /&gt;
* mv ladd09.crt /etc/pki/tls/certs/&lt;br /&gt;
* if selinux is enabled, do this:&lt;br /&gt;
** restorecon -Rv /etc/pki/tls/certs/&lt;br /&gt;
** restorecon -Rv /etc/pki/tls/private/&lt;br /&gt;
** /usr/sbin/setsebool -P httpd_can_network_connect 1&lt;br /&gt;
* open /etc/httpd/conf.d/ssl.conf in a text editor, go to the very bottom and right before the &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; entry, add following text:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SSLCertificateFile /etc/pki/tls/certs/ladd09.crt &lt;br /&gt;
SSLCertificateKeyFile /etc/pki/tls/private/ladd09.key &lt;br /&gt;
&lt;br /&gt;
ProxyPass /elog/ http://localhost:8082/ retry=1&lt;br /&gt;
ProxyPass /      http://localhost:8080/ retry=1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Location /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SSLRequireSSL&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthName &amp;quot;password protected site&amp;quot;&lt;br /&gt;
Require valid-user&lt;br /&gt;
&lt;br /&gt;
# create password file: touch /etc/httpd/htpasswd&lt;br /&gt;
# to add new user or change password: htpasswd /etc/httpd/htpasswd username&lt;br /&gt;
AuthUserFile /etc/httpd/htpasswd&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/Location&amp;gt;&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* comment out duplicate &amp;quot;SSLCertificateFile&amp;quot; and &amp;quot;SSLCertificateKeyFile&amp;quot; elsewhere in the file&lt;br /&gt;
* (optionally) If you got a certificate that is signed by DigiCert or RapidSSL then you&#039;ll need to add a line specifying the certificate chain file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SSLCertificateChainFile /etc/pki/tls/certs/DigiCertCA.crt&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* touch /etc/httpd/htpasswd&lt;br /&gt;
* htpasswd /etc/httpd/htpasswd midas # enter password midas&lt;br /&gt;
* chkconfig httpd on&lt;br /&gt;
* service httpd restart&lt;br /&gt;
* firewall-cmd --add-port=443/tcp --permanent&lt;br /&gt;
* firewall-cmd --reload&lt;br /&gt;
* firewall-cmd --list-all&lt;br /&gt;
* test it&lt;br /&gt;
** test the SSL proxy: https://host/ should yield the midas status page, https://host/elog/ should yield the elog message index&lt;br /&gt;
* in ODB, set &amp;quot;/Elog/URL&amp;quot; to &amp;quot;https://host/elog/&amp;quot;&lt;br /&gt;
* now from the midas status page, the &amp;quot;Elog&amp;quot; button should take us to the https Elog URL&lt;br /&gt;
&lt;br /&gt;
In needed, enable user directories: https://blah/~user in ~user/public_html&lt;br /&gt;
&lt;br /&gt;
* edit /etc/httpd/conf.d/userdir.conf, replace &amp;quot;UserDir disabled&amp;quot; with &amp;quot;UserDir enabled&amp;quot;&lt;br /&gt;
* setsebool -P httpd_enable_homedirs true&lt;br /&gt;
* systemctl restart httpd&lt;br /&gt;
&lt;br /&gt;
== Setup the history mhttpd for faster access to history plots ==&lt;br /&gt;
When running an SSL proxy,&lt;br /&gt;
* start the main mhttpd (&amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;orange&amp;lt;/span&amp;gt; command for old mhttpd, &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;green&amp;lt;/span&amp;gt; for new mhttpd with Mongoose(post August2015):&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8071 -D&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D --oldserver 8071 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* start the history mhttpd&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt; &amp;quot;mhttpd -p 8072 -D -H&amp;quot;&amp;lt;/span&amp;gt; or&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D -H --oldserver 8072 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
* set ODB /History/URL to &amp;quot;http://alphacpc09.cern.ch:8072/HS/&amp;quot;&lt;br /&gt;
* open the MIDAS status page&lt;br /&gt;
* go to the history section, try to open any history plot, observe that the history plot gif image loads correctly, inspect it&#039;s URL (use &amp;quot;copy image URL&amp;quot; or &amp;quot;view source&amp;quot;, etc), it should point to port 8072 causing connection to the history mhttpd.&lt;br /&gt;
* continue with these instructions to setup history mhttpd access through an SSL proxy:&lt;br /&gt;
* setup SSL proxy access (required mod_proxy_html)&lt;br /&gt;
** login as root to the SSL proxy machine&lt;br /&gt;
** on SL5, install the missing mod_proxy_html httpd module:&lt;br /&gt;
** yum install httpd-devel libxml2-devel&lt;br /&gt;
** wget http://apache.webthing.com/mod_proxy_html/mod_proxy_html.tar.bz2&lt;br /&gt;
** tar xjvf mod_proxy_html.tar.bz2 &lt;br /&gt;
** cd mod_proxy_html&lt;br /&gt;
** apxs -c -I. -I/usr/include/libxml2 -i mod_proxy_html.c &lt;br /&gt;
** apxs -c -I. -I/usr/include/libxml2 -i mod_xml2enc.c&lt;br /&gt;
** cd /etc/httpd/conf.d, add this to ssl.conf:&lt;br /&gt;
&lt;br /&gt;
;before the ProxyPass statements:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# proxy the MIDAS web servers  &lt;br /&gt;
LoadModule  xml2enc_module       modules/mod_xml2enc.so  &lt;br /&gt;
LoadModule  proxy_html_module    modules/mod_proxy_html.so  &lt;br /&gt;
ProxyHTMLLinks  a               href  &lt;br /&gt;
ProxyHTMLLinks  link            href  &lt;br /&gt;
ProxyHTMLLinks  img             src  &lt;br /&gt;
#ProxyHTMLEnable On  &lt;br /&gt;
ProxyRequests off  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
;after the ProxyPass statements:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ALPHA1 history access &lt;br /&gt;
ProxyPass /alpha1/history/   http://alphacpc09.cern.ch:8072/HS/  retry=1 &lt;br /&gt;
ProxyPass /alpha1/           http://alphacpc09.cern.ch:8071/     retry=1 &lt;br /&gt;
 &lt;br /&gt;
ProxyHTMLEnable On  &lt;br /&gt;
ProxyHTMLURLMap http://alphacpc09.cern.ch:8072/HS/ /alpha1/history/ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
;adjust:&lt;br /&gt;
*&amp;quot;alpha1&amp;quot; is the experiment name&lt;br /&gt;
*&amp;quot;alphacpc09.cern.ch&amp;quot; is the machine running mhttpd&lt;br /&gt;
*&amp;quot;8071&amp;quot; is the port number of the main mhttpd &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8071 -D&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D --oldserver 8071 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
* &amp;quot;8072&amp;quot; is the port number of the history mhttpd &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8072 -D -H&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D -H --oldserver 8072 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]] [[Category:Buffer]] [[Category:Driver]]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MIDAS_experiment_at_TRIUMF&amp;diff=3602</id>
		<title>Setup MIDAS experiment at TRIUMF</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MIDAS_experiment_at_TRIUMF&amp;diff=3602"/>
		<updated>2026-02-03T17:30:46Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install https proxy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This page describes setting up a MIDAS experiment at TRIUMF. This information can be adapted for other sites.&lt;br /&gt;
&lt;br /&gt;
== Environment variables ==&lt;br /&gt;
* &#039;&#039;&#039;MIDASSYS&#039;&#039;&#039; Base directory of the MIDAS package, midas and mxml should be at the same level.&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_EXPTAB&#039;&#039;&#039; Experiment definition file&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_SERVER_HOST&#039;&#039;&#039; MIDAS host server name for remote midas connections.&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_EXPT_NAME&#039;&#039;&#039; Experiment name&lt;br /&gt;
&lt;br /&gt;
== Standard layout of MIDAS experiment ==&lt;br /&gt;
The following shows the directory layout of a standard MIDAS experiment: &lt;br /&gt;
&lt;br /&gt;
 /home/exptuser/&lt;br /&gt;
                packages/&lt;br /&gt;
                        root                   &amp;lt;---- ROOT&lt;br /&gt;
                        mxml&lt;br /&gt;
                        mscb&lt;br /&gt;
                        midas/                 &amp;lt;---- MIDAS&lt;br /&gt;
                              linux/{lib,bin}       &amp;lt;---- binaries matching the selected 64-bit/32-bit flavour of ROOT&lt;br /&gt;
                              linux-m32/{lib,bin}   &amp;lt;---- limited function 32-bit binaries for 32-bit frontend machines, build by &amp;quot;make linux32&amp;quot;&lt;br /&gt;
                              linux-m64/{lib,bin}   &amp;lt;---- limited function 64-bit binaries (only needed if ROOT and linux/bin are 32-bit)&lt;br /&gt;
                              linux-arm/{lib,bin}   &amp;lt;---- full function ARM cross-compiled using &amp;quot;make linuxarm&amp;quot;&lt;br /&gt;
                              linux-crosscompile/{lib,bin}  &amp;lt;---- cross-compiled limited function binaries for PPC and ARM frontends (see Makefile)&lt;br /&gt;
                        rootana                &amp;lt;---- ROOT analyzer&lt;br /&gt;
                        roody                  &amp;lt;---- graphical online histogram viewer for MIDAS and ROOTANA&lt;br /&gt;
                 online/&lt;br /&gt;
                        exptab                         &amp;lt;---- experiment definition&lt;br /&gt;
                        {.ODB,.SYSTEM,.SYSMSG,etc}.SHM &amp;lt;---- MIDAS shared memory save files&lt;br /&gt;
                        src                            &amp;lt;---- experiment frontend sources&lt;br /&gt;
                        bin,scripts&lt;br /&gt;
                        elog                           &amp;lt;---- MIDAS elog&lt;br /&gt;
                        history                        &amp;lt;---- MIDAS history&lt;br /&gt;
                        data -&amp;gt; /data/exptname/current &amp;lt;---- symlink to the data directory&lt;br /&gt;
 /data/exptname/current                                &amp;lt;---- experiment data directory with ODB save files and MIDAS .mid/.mid.gz data files&lt;br /&gt;
&lt;br /&gt;
== Prepare computers ==&lt;br /&gt;
&lt;br /&gt;
On some operating systems, several MIDAS functions require administrator access:&lt;br /&gt;
&lt;br /&gt;
* on el7 linux (SL7/CC7/CentOS7/RHEL7) - access to mhttpd port 8443 requires special firewall rules, see here: https://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
* on el7 linux - access to mserver to run frontends and other programs on some other computer requires special firewall rules, see here: https://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
* on el7 linux - on the frontend machines (and other machines that will connect to the mserver, the same firewall rule needs to be created (use the IP address of the machine running the mserver)&lt;br /&gt;
&lt;br /&gt;
== Prepare the user account ==&lt;br /&gt;
&amp;lt;div id=&amp;quot;NOTES&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Setup the user account for running this instance of midas. For machines part of the LADD cluster, follow these  [http://daq-plone.triumf.ca/SM/docs/local/NewLaddUser] instructions.&lt;br /&gt;
* check that the account is using the /bin/bash shell&lt;br /&gt;
* make $HOME/.profile look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/echo You must source&lt;br /&gt;
&lt;br /&gt;
export SVN_EDITOR=&amp;quot;emacs -nw&amp;quot;&lt;br /&gt;
export GIT_EDITOR=&amp;quot;emacs -nw&amp;quot;&lt;br /&gt;
export MIDASSYS=$HOME/packages/midas&lt;br /&gt;
export ROOTANASYS=$HOME/packages/rootana&lt;br /&gt;
export MIDAS_EXPTAB=$HOME/online/exptab&lt;br /&gt;
#&lt;br /&gt;
# setup the MIDAS mserver&lt;br /&gt;
#&lt;br /&gt;
case `hostname` in&lt;br /&gt;
daq07*)&lt;br /&gt;
   unset MIDAS_SERVER_HOST&lt;br /&gt;
   ;;&lt;br /&gt;
*)&lt;br /&gt;
   export MIDAS_SERVER_HOST=daq07.triumf.ca:7070&lt;br /&gt;
   ;;&lt;br /&gt;
esac&lt;br /&gt;
#&lt;br /&gt;
# select 64-bit or 32-bit MIDAS and ROOT&lt;br /&gt;
#&lt;br /&gt;
case `uname -i` in&lt;br /&gt;
i386)&lt;br /&gt;
   source /daq/daqshare/olchansk/root/root_v5.34.01_SL62_32/bin/thisroot.sh&lt;br /&gt;
   export PATH=.:$MIDASSYS/linux-m32/bin:$PATH&lt;br /&gt;
   ;;&lt;br /&gt;
*)&lt;br /&gt;
   #source /daq/daqshare/olchansk/root/root_v5.34.34_SL67_64/bin/thisroot.sh&lt;br /&gt;
   source $HOME/packages/root/bin/thisroot.sh&lt;br /&gt;
   export PATH=.:$MIDASSYS/linux/bin:$PATH&lt;br /&gt;
   ;;&lt;br /&gt;
esac&lt;br /&gt;
#&lt;br /&gt;
export PATH=.:$HOME/online/bin:$HOME/packages/roody/bin:$PATH&lt;br /&gt;
#&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* mkdir $HOME/packages&lt;br /&gt;
* Logout and login again, for .cshrc changes to take effect&lt;br /&gt;
&lt;br /&gt;
== Install ROOT ==&lt;br /&gt;
&lt;br /&gt;
* Identify the Linux version: RH9 (Red Hat Linux 9), FC3 (Fedora Core 3), RHEL4/SL4 (Red Hat Enterprise LInux 4/Scientific Linux 4), SL5x, SL6x, (CentOS/CC/SL) el7x: more /etc/redhat-release&lt;br /&gt;
* Decide to use 32-bit or 64-bit ROOT (&#039;uname -a&#039;)&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* ls -l /daq/daqshare/olchansk/root/ ### to see all available ROOT packages&lt;br /&gt;
* ln -s /daq/daqshare/olchansk/root/root_vNNN_VVV_BB root, where NNN is the latest available version of ROOT (&amp;quot;ls -l /daq/daqshare/olchansk/root&amp;quot;), VVV is the Linux version code (RH9, FC3, SL4, etc) and BB is &amp;quot;_32&amp;quot; or &amp;quot;_64&amp;quot; for 32-bit or 64-bit ROOT. For example: /daq/daqshare/olchansk/root/root_v5.10.00_SL40&lt;br /&gt;
* for example: ln -s /daq/daqshare/olchansk/root/root_v5.34.34_el72_64 $HOME/packages/root&lt;br /&gt;
* Check that ROOT works: &amp;quot;source $HOME/packages/root/bin/thisroot.sh; root&amp;quot;. Type &amp;quot;.q&amp;quot; to exit root.&lt;br /&gt;
&lt;br /&gt;
== Install MIDAS ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* (OBSOLETE) svn co svn+ssh://svn@savannah.psi.ch/repos/meg/midas/trunk midas, password &amp;quot;svn&amp;quot;. (password has to be entered twice)&lt;br /&gt;
* (OBSOLETE) svn co svn+ssh://svn@savannah.psi.ch/repos/meg/mxml/trunk mxml&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/midas --recursive&lt;br /&gt;
* (OBSOLETE) git clone https://bitbucket.org/tmidas/mxml&lt;br /&gt;
* (OBSOLETE) git clone https://bitbucket.org/tmidas/mscb&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mxml.git&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mscb.git&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/midas.git&lt;br /&gt;
* cd midas&lt;br /&gt;
* make&lt;br /&gt;
* (only if needed) make linux32 ### build the 32-bit MIDAS libraries&lt;br /&gt;
* ls -l linux/bin/odbedit ### check that odbedit has been created (do not run it yet)&lt;br /&gt;
&lt;br /&gt;
You can see a list of other installation problems at [[Common problems &amp;amp; Debugging recipes]].&lt;br /&gt;
&lt;br /&gt;
;NOTE 1&lt;br /&gt;
: Optional features in MIDAS can be explicitly disabled if desired when making MIDAS using the NO_xxx feature (NO_ROOT,NO_MYSQL,NO_ODBC,NO_SQLITE,NO_MSCB), e.g. &amp;quot;make NO_ROOT=1&amp;quot; to disable ROOT. These NO_xxx Makefile variables are only used to control autodetection.&lt;br /&gt;
&lt;br /&gt;
;NOTE 2&lt;br /&gt;
: Since June 2019 the mxml and mscb packages are submodules of the midas package, so no need to clone them separately. If you have an existing clone of midas but not yet the submodules, you need&lt;br /&gt;
&lt;br /&gt;
 $ git submodule update --init --recursive&lt;br /&gt;
&lt;br /&gt;
: To update both midas and the submodules, you need&lt;br /&gt;
&lt;br /&gt;
 $ git pull --recurse-submodules&lt;br /&gt;
&lt;br /&gt;
== Install ROOTANA ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
* cd rootana&lt;br /&gt;
* make&lt;br /&gt;
&lt;br /&gt;
== Install ROODY ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/roody&lt;br /&gt;
* cd roody&lt;br /&gt;
* make&lt;br /&gt;
* $HOME/packages/roody/bin/roody, run the program&lt;br /&gt;
&lt;br /&gt;
== Install additional additional packages ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/ttriumfdaq/vme&lt;br /&gt;
* git clone https://bitbucket.org/ttriumfdaq/frontends&lt;br /&gt;
&lt;br /&gt;
== Build special versions of MIDAS ==&lt;br /&gt;
&lt;br /&gt;
Build special versions of MIDAS for the case when some MIDAS programs, such as VME frontends, will run on a different computer that may have a different flavour of operating system, i.e. 32-bit linux or an older version of Scientific Linux.&lt;br /&gt;
&lt;br /&gt;
* login to the computer where the frontends will run and:&lt;br /&gt;
* if it is a 32-bit linux: cd $HOME/packages/midas; make linux32&lt;br /&gt;
* if it is a 64-bit linux: cd $HOME/packages/midas; make linux64&lt;br /&gt;
&lt;br /&gt;
* login to the host computer to cross-compile ARM code:&lt;br /&gt;
* if it is an ARM linux: cd $HOME/packages/midas; make linuxarm # may need to install ARM cross compilers&lt;br /&gt;
&lt;br /&gt;
== Prepare VME hardware ==&lt;br /&gt;
&lt;br /&gt;
Hardware check list:&lt;br /&gt;
* VME crate&lt;br /&gt;
* VME processor (supported are V77xx, V7805, V7865)&lt;br /&gt;
* On all VME modules, set the VME address jumpers as described here: http://daq-plone.triumf.ca/SM/docs/local/vme_jumpers&lt;br /&gt;
* run vmescan to confirm correct VME addresses&lt;br /&gt;
** cd $HOME/packages&lt;br /&gt;
** svn checkout https://ladd00.triumf.ca/svn/daqsvn/trunk/vme&lt;br /&gt;
** cd vme&lt;br /&gt;
** make&lt;br /&gt;
** ./vmescan.exe (or _gef.exe, depending on the VME driver in use)&lt;br /&gt;
&lt;br /&gt;
== Install Universe-II VME driver (V7648, V7750, V7805, V7851) ==&lt;br /&gt;
&lt;br /&gt;
* login as root (ssh root@localhost)&lt;br /&gt;
* follow instructions: https://www.triumf.info/wiki/DAQwiki/index.php/VME-CPU#V7648.2C_V7750.2C_V7805.2C_V7851_:_Setup_vme_universe_VME_drivers&lt;br /&gt;
* cd ~/packages/vme; vmescan.exe&lt;br /&gt;
&lt;br /&gt;
== Install Tsi-148 VME driver (V7865) ==&lt;br /&gt;
&lt;br /&gt;
* login as root (ssh root@localhost)&lt;br /&gt;
* follow instructions: https://www.triumf.info/wiki/DAQwiki/index.php/VME-CPU#V7865_and_XVB-602_:_Setup_gefvme.2Ftsi148_VME_drivers&lt;br /&gt;
* cd ~/packages/vme; vmescan_gef.exe&lt;br /&gt;
&lt;br /&gt;
== Setup the experiment environment ==&lt;br /&gt;
&lt;br /&gt;
* Decide which computer will host MIDAS (where MIDAS shared memory buffers will reside). &lt;br /&gt;
: This computer will run the [[mserver]], [[mlogger]] and [[mhttpd]] applications. (It is usually the machine where the MIDAS,ROOT etc. packages have been downloaded). It will be referred to as the host machine (localhost).&lt;br /&gt;
&lt;br /&gt;
The environment is slightly different depending on whether all programs run on the host machine, or whether some programs run on remote host(s) : &lt;br /&gt;
=== ALL programs run on localhost ===&lt;br /&gt;
:If all programs run on the host machine (localhost), it is not necessary to run [[mserver]]. [[Environment Variables#MIDAS_SERVER_HOST|MIDAS_SERVER_HOST]] will not be assigned (see example .cshrc [[#Prepare the user account|above]]).&lt;br /&gt;
&lt;br /&gt;
=== Some programs run on REMOTE host(s) ===&lt;br /&gt;
: &#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; &lt;br /&gt;
# Since August 2015 &#039;&#039;&#039;you must explicitly allow access for clients running on remote machines&#039;&#039;&#039;. To do this, follow the &#039;&#039;&#039;[[Security#MIDAS programs on remote machines|instructions here]]&#039;&#039;&#039;.&lt;br /&gt;
# The example code .cshrc ([[#Prepare the user account|see above]]) should be present on both host and remote machine(s). This will ensure that [[Environment Variables#MIDAS_SERVER_HOST|MIDAS_SERVER_HOST]] will NOT be set for the host machine (localhost), but on a remote machine, MIDAS_SERVER_HOST will be set to the MIDAS host machine. &lt;br /&gt;
# The client [[mserver]] must be started on the MIDAS host machine. Note that multiple experiments can run on the same host machine by starting several instances of [[mserver]] (one for each experiment) running with different ports (and .cshrc would be edited so that MIDAS_SERVER_HOST is set to the appropriate port for the experiment).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
On the host machine:&lt;br /&gt;
* mkdir $HOME/online&lt;br /&gt;
* cd $HOME/online&lt;br /&gt;
* create directories for local programs, sources, elog and history: mkdir bin src elog history&lt;br /&gt;
* create data directory: mkdir -p /ladd/data1/t2kvme5/data; ln -s /ladd/data1/t2kvme5/data $HOME/online&lt;br /&gt;
* create the exptab file &amp;quot;$HOME/online/exptab&amp;quot; following the example below. The first entry (exptname) is the name if the DAQ system (MIDAS experiment name), the second entry (/home/USER/online) is the location of MIDAS shared memory buffers (by convention, $HOME/online), the third entry (kopio03) is your username.&lt;br /&gt;
&amp;lt;pre&amp;gt;exptname /home/kopio03/online kopio03&amp;lt;/pre&amp;gt;&lt;br /&gt;
* logout and login again for all changes to take effect&lt;br /&gt;
&lt;br /&gt;
== Setup experiment startup scripts ==&lt;br /&gt;
* login to the experiment host computer&lt;br /&gt;
* echo $MIDAS_SERVER_HOST ### to check correct value - should be blank&lt;br /&gt;
* create $HOME/online/bin/start_daq.sh, replacing XXX with the hostname of the machine running the experiment (and changing the mserver and mhttpd ports, as needed).&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 # start_daq.sh&lt;br /&gt;
 cd $HOME/online&lt;br /&gt;
 #&lt;br /&gt;
 case `hostname` in XXX*)&lt;br /&gt;
    echo &amp;quot;Good, we are on XXX!&amp;quot;&lt;br /&gt;
    ;;&lt;br /&gt;
 *)&lt;br /&gt;
    echo &amp;quot;The start_daq script should be executed on XXX&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
    ;;&lt;br /&gt;
 esac&lt;br /&gt;
 #&lt;br /&gt;
 odbedit -c clean&lt;br /&gt;
 #   start [[mhttpd]] on default port. (Mongoose https version - see [[mhttpd]] for other options)&lt;br /&gt;
 mhttpd  -D  -a localhost -a XXX.triumf.ca # optionally restrict access to specified hosts&lt;br /&gt;
 #&lt;br /&gt;
 #   start [[mserver]] on default port (use argument -p to use a different port) &lt;br /&gt;
 mserver -D   # access must now be specifically allowed - see [[#Setup the experiment environment|above]]&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;&lt;br /&gt;
 # OR ([[#NOTES|older MIDAS versions]])&lt;br /&gt;
 # mhttpd  -p 8081 -D -a localhost -a XXX.triumf.ca      # optionally restrict access to specified hosts&lt;br /&gt;
 # mserver -p 7071 -D -a localhost -a lxdragon01.triumf.ca -a lxdragon02.triumf.ca -a XXX.triumf.ca # optionally restrict access to specified hosts&lt;br /&gt;
 &amp;lt;/span&amp;gt;&lt;br /&gt;
 #&lt;br /&gt;
 mlogger -D&lt;br /&gt;
 #end file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Run the MIDAS Web Server ==&lt;br /&gt;
Let&#039;s start the MIDAS webserver for the first time:&lt;br /&gt;
&lt;br /&gt;
Start [[mhttpd]] on the &#039;&#039;experiment host&#039;&#039; (localhost) like this:&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&amp;lt;/small&amp;gt;&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhttpd,INFO] ODB subtree /Runinfo corrected successfully&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17892:mongoose,ERROR] cannot find SSL certificate file &amp;quot;/home/agdaq/online/ssl_cert.pem&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17893:mongoose,ERROR] please create SSL certificate file: openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key; openssl x509 -req -days 365 -sha256 -in ssl_cert.csr -signkey ssl_cert.key -out ssl_cert.pem; cat ssl_cert.key &amp;gt;&amp;gt; ssl_cert.pem&lt;br /&gt;
 could not start the mongoose web server, see messages and midas.log, bye!&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a self-signed certificate suitable for initial testing by executing the command printed by mhttpd:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 [mhostpc] openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key; openssl x509 -req -days 365 -sha256 -in ssl_cert.csr -signkey ssl_cert.key -out ssl_cert.pem; cat ssl_cert.key &amp;gt;&amp;gt; ssl_cert.pem&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For production use, you should create a properly signed certificate, see [[Mhttpd#Create an SSL certificate|create your own SSL certificate]] or you should run mhttpd behind an SSL proxy.&lt;br /&gt;
&lt;br /&gt;
Run mhttpd again.&lt;br /&gt;
&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhttpd,INFO] ODB subtree /Runinfo corrected successfully&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot;&lt;br /&gt;
 Mongoose web server will use SSL certificate file &amp;quot;/home/johnfoo/packages/midas/ssl_cert.pem&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17633:mongoose,ERROR] mongoose web server cannot find password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17634:mongoose,ERROR] please create password file: htdigest -c /home/johnfoo/online/htpasswd.txt Default midas&lt;br /&gt;
 could not start the mongoose web server, see messages and midas.log, bye!&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the password file by following the instructions printed by mhttpd. The http digest domain name is the experiment name, suggested default user name is &amp;quot;midas&amp;quot;. You will be asked to type in a password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 [mhostpc] htdigest -c /home/johnfoo/online/htpasswd.txt exptname midas&lt;br /&gt;
 Adding password for midas in realm exptname.&lt;br /&gt;
 New password:&lt;br /&gt;
 Re-type new password:&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
It is a good idea to set the password file {{Filepath|path=htpasswd.txt}} readable and writable by owner only.&lt;br /&gt;
&lt;br /&gt;
Now restart  {{Utility|name=mhttpd}}&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot; **see note&lt;br /&gt;
 Mongoose web server will use SSL certificate file &amp;quot;/home/suz/packages/midas/ssl_cert.pem&amp;quot;&lt;br /&gt;
 Mongoose web server will use authentication realm &amp;quot;Default&amp;quot;, password file &amp;quot;./htpasswd.txt&amp;quot;&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Now point a web browser running on the same host computer (localhost) to https://localhost:8443&lt;br /&gt;
If the web browser is running on a different computer, go to URL of the form&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 https://mhostpc.triumf.ca:8443  (substitute your host machine name and domain for &amp;quot;mhostpc.triumf.ca&amp;quot;)&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
If you are using the default SSL certificate you will probably get a message: &amp;quot;This Connection is Untrusted&amp;quot;.  Click &amp;quot;I understand the risks&amp;quot; and add an exception. This is because the test certificate is self-signed. Then confirm an exception. &lt;br /&gt;
&lt;br /&gt;
If instead you get a &amp;quot;connection refused&amp;quot; error, the midas host pc may have the firewall enabled. To make a firewall exception for MIDAS, follow instructions here http://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
&lt;br /&gt;
You should then see an authentication box asking you for the user name and password. The user name is &amp;quot;midas&amp;quot;. Enter the password you just created. The Midas [[Status Page]] should appear with multiple buttons for run control as well as equipment listing (no equipments will be listed as yet) and application listings. Please refer to [[mhttpd]] (the MIDAS Web-based Run Control utility) for further information. You can start and stop runs from the main status page, and use the [[ODB Page]] to access the database (ODB).&lt;br /&gt;
&lt;br /&gt;
; Note &lt;br /&gt;
: Default ports of 8080 and 8443 are used by [[mhttpd]]. If these ports are in use on your machine, start &amp;lt;span style=&amp;quot;color:darkcyan;font-style:italic&amp;quot;&amp;gt;mhttpd&amp;lt;/span&amp;gt; with alternative ports, e.g.&lt;br /&gt;
       &amp;lt;small&amp;gt;[mhostpc] mhttpd --https 8448 --http 8089&amp;lt;/small&amp;gt;&lt;br /&gt;
: or see [[Mhttpd#Usage]] to change the default ports.&lt;br /&gt;
&lt;br /&gt;
== Setup experiment database (ODB) ==&lt;br /&gt;
&lt;br /&gt;
* run $HOME/online/bin/start_daq.sh&lt;br /&gt;
&lt;br /&gt;
* odbedit, run these commands: (replace user names and directory names)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set &amp;quot;/Logger/Message file&amp;quot; &amp;quot;/home/kopio03/online/midas.log&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Data Dir&amp;quot;     &amp;quot;/home/kopio03/online/data&amp;quot;&lt;br /&gt;
create STRING &amp;quot;/Logger/History dir&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/History dir&amp;quot;  &amp;quot;/home/kopio03/online/history&amp;quot;&lt;br /&gt;
create STRING &amp;quot;/Logger/Elog dir&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Elog dir&amp;quot;     &amp;quot;/home/kopio03/online/elog&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/ODB dump file&amp;quot; &amp;quot;/home/kopio03/online/history/run%05d.xml&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/ODB dump&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Filename&amp;quot; &amp;quot;run%05dsub%03d.mid.gz&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Subrun byte limit&amp;quot; &amp;quot;1000000000&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Compression&amp;quot;   1&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/ODB Dump&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/Logger/Required&amp;quot; y&lt;br /&gt;
set &amp;quot;/Programs/Logger/Start command&amp;quot; &amp;quot;mlogger -D&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/fevme/Required&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/fevme/Start command&amp;quot; &amp;quot;ssh -n lxdaq09 $HOME/online/src/fevme_gef.exe -O&amp;quot;&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* open web browser e.g. firefox.&lt;br /&gt;
* go to the midas status page at https://localhost:8443  (default port). &lt;br /&gt;
** if running [[mhttpd]] with Mongoose HTTPS/OpenSSL (the default) for the first time, you will need to create a password file. Follow the instructions (see [[mhttpd#HTTPS/SSL server (Mongoose)]] for details).&lt;br /&gt;
** For other options (i.e. HTTPS/SSL proxy) see [[#Secure MIDAS and ELOG Web access]] &lt;br /&gt;
*&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;OR open the midas status page at http://localhost:8081 ([[#NOTES|older MIDAS versions]])&lt;br /&gt;
* midas status page will show most stuff &amp;quot;red&amp;quot; as nothing is running yet&lt;br /&gt;
* DON&#039;T DO THIS YET run ./fevme.exe (on the computer with the VME interface, could be different from computer hosting the experiment), observe that corresponding equipments have been created&lt;br /&gt;
* save the url bookmark to the &amp;quot;personal toolbar&amp;quot;&lt;br /&gt;
* go to the Programs page, stop mlogger, stop fevme, start mlogger, start fevme&lt;br /&gt;
* go to the Status page, start run, stop run&lt;br /&gt;
* go back to the Status page, everything should be green&lt;br /&gt;
* start a run&lt;br /&gt;
* send signals to the ADC gate&lt;br /&gt;
* you should be getting events&lt;br /&gt;
* to look at data, proceed with setting up the [[ROOTANA|ROOT Analyzer]].&lt;br /&gt;
&lt;br /&gt;
== Start DAQ programs at boot time ==&lt;br /&gt;
&lt;br /&gt;
* add this to /etc/rc.local (replace username and location of the start_daq script)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
su - alpha -c /home/alpha/online/bin/start_daq.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setup local software version control ==&lt;br /&gt;
&lt;br /&gt;
Version control for experiment source code is setup using &amp;quot;git&amp;quot; (http://git-scm.com/)&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/online&lt;br /&gt;
* git init&lt;br /&gt;
* git add exptab&lt;br /&gt;
* git add bin/start_daq.sh&lt;br /&gt;
* git add .gitignore ### contents can be&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
*~&lt;br /&gt;
*.o&lt;br /&gt;
*.exe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* git add src/Makefile src/*.cxx ...&lt;br /&gt;
* git commit -a&lt;br /&gt;
&lt;br /&gt;
== Adjust MIDAS buffer sizes ==&lt;br /&gt;
&lt;br /&gt;
Default MIDAS SYSTEM buffer size is 8 Mbytes, fairly small for high-data-rate experiments. The rule of thumb is to have at least a few seconds worth of buffer space available. For example, if event size is 10 Kbytes and the event rate is 1 kHz, data rate is 10*10^3*1*10^3 = 10 Mbytes/sec. To buffer 10 seconds of data we need 100 Mbytes of buffer space.&lt;br /&gt;
&lt;br /&gt;
To resize the MIDAS event buffers (SYSTEM, etc) do this:&lt;br /&gt;
* stop all frontends, stop mlogger&lt;br /&gt;
* start odbedit:&lt;br /&gt;
** cd &amp;quot;/Experiment/Buffer sizes&amp;quot;&lt;br /&gt;
** set SYSTEM 100000000&lt;br /&gt;
* run &amp;quot;mdump -z SYSTEM&amp;quot;&lt;br /&gt;
* if mdump complains about the size of .SYSTEM.SHM, remove it, try again.&lt;br /&gt;
* ls -l /dev/shm ### to observe that the size of shared memory is correct&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Secure MIDAS and ELOG Web access  ==&lt;br /&gt;
In versions prior to May 2015, the default web access to MIDAS and ELOG uses the &amp;quot;http:&amp;quot; protocol which is insecure. In this case, all information is transmitted as clear text meaning that secret, confidential and sensitive information (such as the MIDAS and ELOG passwords and usernames) can be stolen &amp;quot;easily&amp;quot;. This means that even &amp;quot;password protected&amp;quot; MIDAS and ELOG pages are not really protected if accessed using the &amp;quot;http&amp;quot; method. &lt;br /&gt;
 &lt;br /&gt;
Better security for HTTP is gained by using a password protected &#039;&#039;&#039;SSL (https) proxy&#039;&#039;&#039;. (It does not provide absolute security because of remaining problems with the security of SSL certificates, security of passwords, etc). Setting up an SSL (https) proxy is described [[#Setting up an HTTP proxy|below]].&lt;br /&gt;
&lt;br /&gt;
Since May 2015, an &#039;&#039;alternative secure option&#039;&#039; to setting up an HTTP proxy is available to users of MIDAS. Recent versions of elogd (ELOG) do support SSL https:// connections, and [[#mhttpd with HTTPS/SSL server (Mongoose)]] is now available.  This option is the default, and provides a similar level of security to an HTTP proxy. &lt;br /&gt;
&lt;br /&gt;
See [[Security#Web Access]] for a comparison of these two secure options.&lt;br /&gt;
  &lt;br /&gt;
=== mhttpd with HTTPS/SSL server (Mongoose) ===&lt;br /&gt;
&lt;br /&gt;
Since May 2015 the MIDAS web server [[mhttpd]] is explicitly linked with OpenSSL to provide secure HTTPS connections via the [https://bitbucket.org/tmidas/midas/src/ecb9a8537448a8a43f7f9a2bfdb82e578208cde3/doc/mongoose/?at=develop Mongoose] web server (see [[mhttpd]]). With this version, default web access to MIDAS uses the &amp;quot;https&amp;quot; protocol. Web access to {{Utility|name=mhttpd}} can be restricted by using the  &amp;quot;-a hostname&amp;quot; switch of [[mhttpd]]. The first time {{Utility|name=mhttpd}} is run, a password file must be created. An SSL certificate is also required. See [[mhttpd#HTTPS/SSL server (Mongoose)|HTTPS/SSL server (Mongoose)]] for instructions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== mhttpd using an HTTPS/SSL proxy ===&lt;br /&gt;
&lt;br /&gt;
THESE INSTRUCTIONS ARE WRONG, DO NOT DO THIS. See instead the [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog TRIUMF DAQ site].&lt;br /&gt;
&lt;br /&gt;
An [[#Setting up an HTTP proxy|HTTP proxy]] must be set up. This is the only way of securing older version of [[mhttpd]] (pre August 2015). Older versions of mhttpd are started using the -p port option  e.g.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt; mhttpd  -D -p 8080  &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run a new version of mhttpd using an HTTP proxy, use the options provided to run the old (non-Mongoose) webserver on a given port, i.e.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;  mhttpd --oldserver 8080 --nomg   -D  &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using an SSL proxy, only access from the SSL proxy (and maybe some special trusted machines) should be permitted. &lt;br /&gt;
This is done using the &amp;quot;-a hostname&amp;quot; switch of [[mhttpd]]. Normally there will be only &amp;quot;-a localhost&amp;quot; switch, enabling access only for the local machine (where the SSL proxy is running). Additional &amp;quot;-a hostname&amp;quot; switches enable access from listed local machines. No &amp;quot;-a xxx&amp;quot; enables access from everywhere (defeating the purpose of the SSL proxy, unless access controls are enforced elsewhere, i.e. by a site firewall or by local firewall rules).&lt;br /&gt;
&lt;br /&gt;
== Setting up an HTTP proxy ==&lt;br /&gt;
In this example, we use APACHE HTTPD to password-protect a typical midas/mhttpd and elog installation.&lt;br /&gt;
&lt;br /&gt;
In this configuration, one uses the Linux stock httpd that accepts encrypted https:// connections and forwards them to mhttpd and elogd. Instead of (or in addition to) using mhttpd and elogd passwords, one configures password protection in httpd via the regular apache httpd password mechanisms (htpasswd, etc).&lt;br /&gt;
&lt;br /&gt;
Recent versions of elogd do support SSL https:// connections, but if one is running an SSL proxy for anyway, it is simpler to run both through the same SSL proxy using the same SSL host certificate and the same httpd password file.&lt;br /&gt;
&lt;br /&gt;
=== Restricting http: access to elogd ===&lt;br /&gt;
;Note&lt;br /&gt;
:Recent versions of elogd do support SSL https:// connections. The following information is for those using an HTTP proxy (see above).&lt;br /&gt;
&lt;br /&gt;
For elogd, this is done using the &amp;quot;-n localhost&amp;quot; switch with enables only access from the same machine if present, or access from anywhere is absent (defeating the purpose of the SSL proxy, unless access controls are enforced elsewhere).&lt;br /&gt;
&lt;br /&gt;
(It is recommended to run elogd from the same user as the main daq user and to keep elogd.cfg and all logbooks in the home directory of this user, where they are captured by the normal site backup system)&lt;br /&gt;
&lt;br /&gt;
== Install standalone elog ==&lt;br /&gt;
&lt;br /&gt;
* login into the user account that will run the elog&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/ritt/elog&lt;br /&gt;
* cd elog&lt;br /&gt;
* make&lt;br /&gt;
* create new file start_elogd with this contents:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
killall elogd&lt;br /&gt;
sleep 1&lt;br /&gt;
killall -KILL elogd&lt;br /&gt;
sleep 1&lt;br /&gt;
$HOME/packages/elog/elogd -n localhost -x -c $HOME/packages/elog/elogd.cfg -p 8082 -D&lt;br /&gt;
&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* chmod a+x start_elogd&lt;br /&gt;
* edit elogd.cfg to read:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[global]&lt;br /&gt;
port = 8082&lt;br /&gt;
SMTP host = smtp.triumf.ca&lt;br /&gt;
URL = https://titan00.triumf.ca/elog/&lt;br /&gt;
&lt;br /&gt;
Reverse sort = 1&lt;br /&gt;
Display Mode = full&lt;br /&gt;
&lt;br /&gt;
#List Menu commands = New, Find, Admin, Help&lt;br /&gt;
#Menu commands = New, Edit, Reply, Find, Duplicate, Help&lt;br /&gt;
&lt;br /&gt;
Entries Per Page = 30&lt;br /&gt;
Supress Email on edit = 1&lt;br /&gt;
Default encoding = 1&lt;br /&gt;
Page title = TITAN ELOG&lt;br /&gt;
Resolve host names = 1&lt;br /&gt;
&lt;br /&gt;
Logfile = /home/titan/packages/elog/elogd.log&lt;br /&gt;
#Logging level = 3&lt;br /&gt;
&lt;br /&gt;
[midas]&lt;br /&gt;
&lt;br /&gt;
List page Title = T2K M11 MIDAS ELOG&lt;br /&gt;
Comment = T2K M11 MIDAS ELOG&lt;br /&gt;
Page Title = T2K M11 MIDAS ELOG&lt;br /&gt;
RSS Title = [$logbook - $type - $system] $subject, posted by $author&lt;br /&gt;
&lt;br /&gt;
Attributes = Author, Subject, Run, Type, System&lt;br /&gt;
Show Attributes Edit = Run, Author, Subject, Type, System&lt;br /&gt;
Required Attributes = Author, Type, System, Subject&lt;br /&gt;
&lt;br /&gt;
Options Type = Routine, Reply, Shift Summary, Modification, Question, Info, Problem&lt;br /&gt;
Options System = General, DAQ, Beamline&lt;br /&gt;
&lt;br /&gt;
Preset Run = $shell(MIDASSYS=. /home/t2km11/packages/midas/linux/bin/odbedit -d Runinfo -c &#039;ls -v \&amp;quot;run number\&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
Preset On Reply Type = Reply&lt;br /&gt;
Preset On Reply Run = $shell(MIDASSYS=. /home/t2km11/packages/midas/linux/bin/odbedit -d Runinfo -c &#039;ls -v \&amp;quot;run number\&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
List Display = Date, Subject, Type, System, Author, ID&lt;br /&gt;
Quick Filter = Date, Type, ID&lt;br /&gt;
&lt;br /&gt;
Remove on reply = Author&lt;br /&gt;
Quote on reply = 1&lt;br /&gt;
&lt;br /&gt;
Use lock = 1&lt;br /&gt;
&lt;br /&gt;
************* Email Functionality ****************&lt;br /&gt;
&lt;br /&gt;
Use Email Subject = [T2KM11 - $System] $Subject&lt;br /&gt;
Omit Email To = 1&lt;br /&gt;
&lt;br /&gt;
Email System General = xxx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* ./start_elogd &amp;amp;&lt;br /&gt;
* firefox http://localhost:8082 # hould show the elog message index&lt;br /&gt;
&lt;br /&gt;
To start elogd automatically when the machine is rebooted, login as root and&lt;br /&gt;
* add this text to /etc/rc.local:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
su - titan -c &amp;quot;/home/titan/packages/elog/start_elogd&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* chmod a+x /etc/rc.local&lt;br /&gt;
* systemctl start rc-local&lt;br /&gt;
&lt;br /&gt;
To import elog entries from the mhttpd elog, do this:&lt;br /&gt;
&lt;br /&gt;
* cd ~/packages/elog/logbooks&lt;br /&gt;
* ln -s /home/t2km11/online/elog midas&lt;br /&gt;
* cd midas&lt;br /&gt;
* ~/packages/elog/elconv)&lt;br /&gt;
&lt;br /&gt;
== Install https proxy ==&lt;br /&gt;
&lt;br /&gt;
THESE INSTRUCTIONS ARE OBSOLETE, INSTEAD, &lt;br /&gt;
* GO HERE: https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog&lt;br /&gt;
* AND GO HERE: https://midas.triumf.ca/MidasWiki/index.php/Quickstart_Linux#Run_the_MIDAS_Web_Server&lt;br /&gt;
&lt;br /&gt;
FOLLOWING INSTRUCTIONS ARE OBSOLETE...&lt;br /&gt;
&lt;br /&gt;
* login as root to the https proxy machine&lt;br /&gt;
* cd ~root&lt;br /&gt;
* yum install mod_ssl&lt;br /&gt;
* yum install crypto-utils # see http://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_monitoring_of_HTTPS_certificates&lt;br /&gt;
* create a certificate request (replace ladd09 with your hostname): openssl req -new -nodes -newkey rsa:2048 -sha256 -out ladd09.csr -keyout ladd09.key (answer: CA, BC, Vancouver, TRIUMF, DAQ, ladd09.triumf.ca, email@email.com&lt;br /&gt;
* sign it by TRIUMF:&lt;br /&gt;
** mail -s &amp;quot;Certificate request&amp;quot; yourself@email.com &amp;amp;lt; ladd09.csr&lt;br /&gt;
** forward this request to Andrew Daviel&lt;br /&gt;
** he will email the signed crt file, copy it to this system as ladd09.crt&lt;br /&gt;
* sign it yourself: openssl x509 -req -days 365 -sha256 -in ladd09.csr -signkey ladd09.key -out ladd09.crt&lt;br /&gt;
* (if the certificate expires, renew it by signing it again)&lt;br /&gt;
* Additional commands for working with certificates:&lt;br /&gt;
** explore the private key: openssl pkey -in ladd09.key -text -noout&lt;br /&gt;
** explore the certificate request: openssl req -in ladd00.csr -text -noout&lt;br /&gt;
** explore the certificate: openssl x509 -in ladd09.crt -noout -text&lt;br /&gt;
* move certificate files to proper system locations:&lt;br /&gt;
* mv ladd09.key  /etc/pki/tls/private/&lt;br /&gt;
* mv ladd09.crt /etc/pki/tls/certs/&lt;br /&gt;
* if selinux is enabled, do this:&lt;br /&gt;
** restorecon -Rv /etc/pki/tls/certs/&lt;br /&gt;
** restorecon -Rv /etc/pki/tls/private/&lt;br /&gt;
** /usr/sbin/setsebool -P httpd_can_network_connect 1&lt;br /&gt;
* open /etc/httpd/conf.d/ssl.conf in a text editor, go to the very bottom and right before the &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; entry, add following text:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SSLCertificateFile /etc/pki/tls/certs/ladd09.crt &lt;br /&gt;
SSLCertificateKeyFile /etc/pki/tls/private/ladd09.key &lt;br /&gt;
&lt;br /&gt;
ProxyPass /elog/ http://localhost:8082/ retry=1&lt;br /&gt;
ProxyPass /      http://localhost:8080/ retry=1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Location /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SSLRequireSSL&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthName &amp;quot;password protected site&amp;quot;&lt;br /&gt;
Require valid-user&lt;br /&gt;
&lt;br /&gt;
# create password file: touch /etc/httpd/htpasswd&lt;br /&gt;
# to add new user or change password: htpasswd /etc/httpd/htpasswd username&lt;br /&gt;
AuthUserFile /etc/httpd/htpasswd&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/Location&amp;gt;&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* comment out duplicate &amp;quot;SSLCertificateFile&amp;quot; and &amp;quot;SSLCertificateKeyFile&amp;quot; elsewhere in the file&lt;br /&gt;
* (optionally) If you got a certificate that is signed by DigiCert or RapidSSL then you&#039;ll need to add a line specifying the certificate chain file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SSLCertificateChainFile /etc/pki/tls/certs/DigiCertCA.crt&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* touch /etc/httpd/htpasswd&lt;br /&gt;
* htpasswd /etc/httpd/htpasswd midas # enter password midas&lt;br /&gt;
* chkconfig httpd on&lt;br /&gt;
* service httpd restart&lt;br /&gt;
* firewall-cmd --add-port=443/tcp --permanent&lt;br /&gt;
* firewall-cmd --reload&lt;br /&gt;
* firewall-cmd --list-all&lt;br /&gt;
* test it&lt;br /&gt;
** test the SSL proxy: https://host/ should yield the midas status page, https://host/elog/ should yield the elog message index&lt;br /&gt;
* in ODB, set &amp;quot;/Elog/URL&amp;quot; to &amp;quot;https://host/elog/&amp;quot;&lt;br /&gt;
* now from the midas status page, the &amp;quot;Elog&amp;quot; button should take us to the https Elog URL&lt;br /&gt;
&lt;br /&gt;
In needed, enable user directories: https://blah/~user in ~user/public_html&lt;br /&gt;
&lt;br /&gt;
* edit /etc/httpd/conf.d/userdir.conf, replace &amp;quot;UserDir disabled&amp;quot; with &amp;quot;UserDir enabled&amp;quot;&lt;br /&gt;
* setsebool -P httpd_enable_homedirs true&lt;br /&gt;
* systemctl restart httpd&lt;br /&gt;
&lt;br /&gt;
== Setup the history mhttpd for faster access to history plots ==&lt;br /&gt;
When running an SSL proxy,&lt;br /&gt;
* start the main mhttpd (&amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;orange&amp;lt;/span&amp;gt; command for old mhttpd, &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;green&amp;lt;/span&amp;gt; for new mhttpd with Mongoose(post August2015):&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8071 -D&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D --oldserver 8071 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* start the history mhttpd&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt; &amp;quot;mhttpd -p 8072 -D -H&amp;quot;&amp;lt;/span&amp;gt; or&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D -H --oldserver 8072 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
* set ODB /History/URL to &amp;quot;http://alphacpc09.cern.ch:8072/HS/&amp;quot;&lt;br /&gt;
* open the MIDAS status page&lt;br /&gt;
* go to the history section, try to open any history plot, observe that the history plot gif image loads correctly, inspect it&#039;s URL (use &amp;quot;copy image URL&amp;quot; or &amp;quot;view source&amp;quot;, etc), it should point to port 8072 causing connection to the history mhttpd.&lt;br /&gt;
* continue with these instructions to setup history mhttpd access through an SSL proxy:&lt;br /&gt;
* setup SSL proxy access (required mod_proxy_html)&lt;br /&gt;
** login as root to the SSL proxy machine&lt;br /&gt;
** on SL5, install the missing mod_proxy_html httpd module:&lt;br /&gt;
** yum install httpd-devel libxml2-devel&lt;br /&gt;
** wget http://apache.webthing.com/mod_proxy_html/mod_proxy_html.tar.bz2&lt;br /&gt;
** tar xjvf mod_proxy_html.tar.bz2 &lt;br /&gt;
** cd mod_proxy_html&lt;br /&gt;
** apxs -c -I. -I/usr/include/libxml2 -i mod_proxy_html.c &lt;br /&gt;
** apxs -c -I. -I/usr/include/libxml2 -i mod_xml2enc.c&lt;br /&gt;
** cd /etc/httpd/conf.d, add this to ssl.conf:&lt;br /&gt;
&lt;br /&gt;
;before the ProxyPass statements:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# proxy the MIDAS web servers  &lt;br /&gt;
LoadModule  xml2enc_module       modules/mod_xml2enc.so  &lt;br /&gt;
LoadModule  proxy_html_module    modules/mod_proxy_html.so  &lt;br /&gt;
ProxyHTMLLinks  a               href  &lt;br /&gt;
ProxyHTMLLinks  link            href  &lt;br /&gt;
ProxyHTMLLinks  img             src  &lt;br /&gt;
#ProxyHTMLEnable On  &lt;br /&gt;
ProxyRequests off  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
;after the ProxyPass statements:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ALPHA1 history access &lt;br /&gt;
ProxyPass /alpha1/history/   http://alphacpc09.cern.ch:8072/HS/  retry=1 &lt;br /&gt;
ProxyPass /alpha1/           http://alphacpc09.cern.ch:8071/     retry=1 &lt;br /&gt;
 &lt;br /&gt;
ProxyHTMLEnable On  &lt;br /&gt;
ProxyHTMLURLMap http://alphacpc09.cern.ch:8072/HS/ /alpha1/history/ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
;adjust:&lt;br /&gt;
*&amp;quot;alpha1&amp;quot; is the experiment name&lt;br /&gt;
*&amp;quot;alphacpc09.cern.ch&amp;quot; is the machine running mhttpd&lt;br /&gt;
*&amp;quot;8071&amp;quot; is the port number of the main mhttpd &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8071 -D&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D --oldserver 8071 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
* &amp;quot;8072&amp;quot; is the port number of the history mhttpd &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8072 -D -H&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D -H --oldserver 8072 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]] [[Category:Buffer]] [[Category:Driver]]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MIDAS_experiment_at_TRIUMF&amp;diff=3601</id>
		<title>Setup MIDAS experiment at TRIUMF</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MIDAS_experiment_at_TRIUMF&amp;diff=3601"/>
		<updated>2026-02-03T17:30:09Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Secure MIDAS and ELOG Web access */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This page describes setting up a MIDAS experiment at TRIUMF. This information can be adapted for other sites.&lt;br /&gt;
&lt;br /&gt;
== Environment variables ==&lt;br /&gt;
* &#039;&#039;&#039;MIDASSYS&#039;&#039;&#039; Base directory of the MIDAS package, midas and mxml should be at the same level.&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_EXPTAB&#039;&#039;&#039; Experiment definition file&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_SERVER_HOST&#039;&#039;&#039; MIDAS host server name for remote midas connections.&lt;br /&gt;
* &#039;&#039;&#039;MIDAS_EXPT_NAME&#039;&#039;&#039; Experiment name&lt;br /&gt;
&lt;br /&gt;
== Standard layout of MIDAS experiment ==&lt;br /&gt;
The following shows the directory layout of a standard MIDAS experiment: &lt;br /&gt;
&lt;br /&gt;
 /home/exptuser/&lt;br /&gt;
                packages/&lt;br /&gt;
                        root                   &amp;lt;---- ROOT&lt;br /&gt;
                        mxml&lt;br /&gt;
                        mscb&lt;br /&gt;
                        midas/                 &amp;lt;---- MIDAS&lt;br /&gt;
                              linux/{lib,bin}       &amp;lt;---- binaries matching the selected 64-bit/32-bit flavour of ROOT&lt;br /&gt;
                              linux-m32/{lib,bin}   &amp;lt;---- limited function 32-bit binaries for 32-bit frontend machines, build by &amp;quot;make linux32&amp;quot;&lt;br /&gt;
                              linux-m64/{lib,bin}   &amp;lt;---- limited function 64-bit binaries (only needed if ROOT and linux/bin are 32-bit)&lt;br /&gt;
                              linux-arm/{lib,bin}   &amp;lt;---- full function ARM cross-compiled using &amp;quot;make linuxarm&amp;quot;&lt;br /&gt;
                              linux-crosscompile/{lib,bin}  &amp;lt;---- cross-compiled limited function binaries for PPC and ARM frontends (see Makefile)&lt;br /&gt;
                        rootana                &amp;lt;---- ROOT analyzer&lt;br /&gt;
                        roody                  &amp;lt;---- graphical online histogram viewer for MIDAS and ROOTANA&lt;br /&gt;
                 online/&lt;br /&gt;
                        exptab                         &amp;lt;---- experiment definition&lt;br /&gt;
                        {.ODB,.SYSTEM,.SYSMSG,etc}.SHM &amp;lt;---- MIDAS shared memory save files&lt;br /&gt;
                        src                            &amp;lt;---- experiment frontend sources&lt;br /&gt;
                        bin,scripts&lt;br /&gt;
                        elog                           &amp;lt;---- MIDAS elog&lt;br /&gt;
                        history                        &amp;lt;---- MIDAS history&lt;br /&gt;
                        data -&amp;gt; /data/exptname/current &amp;lt;---- symlink to the data directory&lt;br /&gt;
 /data/exptname/current                                &amp;lt;---- experiment data directory with ODB save files and MIDAS .mid/.mid.gz data files&lt;br /&gt;
&lt;br /&gt;
== Prepare computers ==&lt;br /&gt;
&lt;br /&gt;
On some operating systems, several MIDAS functions require administrator access:&lt;br /&gt;
&lt;br /&gt;
* on el7 linux (SL7/CC7/CentOS7/RHEL7) - access to mhttpd port 8443 requires special firewall rules, see here: https://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
* on el7 linux - access to mserver to run frontends and other programs on some other computer requires special firewall rules, see here: https://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
* on el7 linux - on the frontend machines (and other machines that will connect to the mserver, the same firewall rule needs to be created (use the IP address of the machine running the mserver)&lt;br /&gt;
&lt;br /&gt;
== Prepare the user account ==&lt;br /&gt;
&amp;lt;div id=&amp;quot;NOTES&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Setup the user account for running this instance of midas. For machines part of the LADD cluster, follow these  [http://daq-plone.triumf.ca/SM/docs/local/NewLaddUser] instructions.&lt;br /&gt;
* check that the account is using the /bin/bash shell&lt;br /&gt;
* make $HOME/.profile look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/echo You must source&lt;br /&gt;
&lt;br /&gt;
export SVN_EDITOR=&amp;quot;emacs -nw&amp;quot;&lt;br /&gt;
export GIT_EDITOR=&amp;quot;emacs -nw&amp;quot;&lt;br /&gt;
export MIDASSYS=$HOME/packages/midas&lt;br /&gt;
export ROOTANASYS=$HOME/packages/rootana&lt;br /&gt;
export MIDAS_EXPTAB=$HOME/online/exptab&lt;br /&gt;
#&lt;br /&gt;
# setup the MIDAS mserver&lt;br /&gt;
#&lt;br /&gt;
case `hostname` in&lt;br /&gt;
daq07*)&lt;br /&gt;
   unset MIDAS_SERVER_HOST&lt;br /&gt;
   ;;&lt;br /&gt;
*)&lt;br /&gt;
   export MIDAS_SERVER_HOST=daq07.triumf.ca:7070&lt;br /&gt;
   ;;&lt;br /&gt;
esac&lt;br /&gt;
#&lt;br /&gt;
# select 64-bit or 32-bit MIDAS and ROOT&lt;br /&gt;
#&lt;br /&gt;
case `uname -i` in&lt;br /&gt;
i386)&lt;br /&gt;
   source /daq/daqshare/olchansk/root/root_v5.34.01_SL62_32/bin/thisroot.sh&lt;br /&gt;
   export PATH=.:$MIDASSYS/linux-m32/bin:$PATH&lt;br /&gt;
   ;;&lt;br /&gt;
*)&lt;br /&gt;
   #source /daq/daqshare/olchansk/root/root_v5.34.34_SL67_64/bin/thisroot.sh&lt;br /&gt;
   source $HOME/packages/root/bin/thisroot.sh&lt;br /&gt;
   export PATH=.:$MIDASSYS/linux/bin:$PATH&lt;br /&gt;
   ;;&lt;br /&gt;
esac&lt;br /&gt;
#&lt;br /&gt;
export PATH=.:$HOME/online/bin:$HOME/packages/roody/bin:$PATH&lt;br /&gt;
#&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* mkdir $HOME/packages&lt;br /&gt;
* Logout and login again, for .cshrc changes to take effect&lt;br /&gt;
&lt;br /&gt;
== Install ROOT ==&lt;br /&gt;
&lt;br /&gt;
* Identify the Linux version: RH9 (Red Hat Linux 9), FC3 (Fedora Core 3), RHEL4/SL4 (Red Hat Enterprise LInux 4/Scientific Linux 4), SL5x, SL6x, (CentOS/CC/SL) el7x: more /etc/redhat-release&lt;br /&gt;
* Decide to use 32-bit or 64-bit ROOT (&#039;uname -a&#039;)&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* ls -l /daq/daqshare/olchansk/root/ ### to see all available ROOT packages&lt;br /&gt;
* ln -s /daq/daqshare/olchansk/root/root_vNNN_VVV_BB root, where NNN is the latest available version of ROOT (&amp;quot;ls -l /daq/daqshare/olchansk/root&amp;quot;), VVV is the Linux version code (RH9, FC3, SL4, etc) and BB is &amp;quot;_32&amp;quot; or &amp;quot;_64&amp;quot; for 32-bit or 64-bit ROOT. For example: /daq/daqshare/olchansk/root/root_v5.10.00_SL40&lt;br /&gt;
* for example: ln -s /daq/daqshare/olchansk/root/root_v5.34.34_el72_64 $HOME/packages/root&lt;br /&gt;
* Check that ROOT works: &amp;quot;source $HOME/packages/root/bin/thisroot.sh; root&amp;quot;. Type &amp;quot;.q&amp;quot; to exit root.&lt;br /&gt;
&lt;br /&gt;
== Install MIDAS ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* (OBSOLETE) svn co svn+ssh://svn@savannah.psi.ch/repos/meg/midas/trunk midas, password &amp;quot;svn&amp;quot;. (password has to be entered twice)&lt;br /&gt;
* (OBSOLETE) svn co svn+ssh://svn@savannah.psi.ch/repos/meg/mxml/trunk mxml&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/midas --recursive&lt;br /&gt;
* (OBSOLETE) git clone https://bitbucket.org/tmidas/mxml&lt;br /&gt;
* (OBSOLETE) git clone https://bitbucket.org/tmidas/mscb&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mxml.git&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mscb.git&lt;br /&gt;
* (IF BITBUCKET IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/midas.git&lt;br /&gt;
* cd midas&lt;br /&gt;
* make&lt;br /&gt;
* (only if needed) make linux32 ### build the 32-bit MIDAS libraries&lt;br /&gt;
* ls -l linux/bin/odbedit ### check that odbedit has been created (do not run it yet)&lt;br /&gt;
&lt;br /&gt;
You can see a list of other installation problems at [[Common problems &amp;amp; Debugging recipes]].&lt;br /&gt;
&lt;br /&gt;
;NOTE 1&lt;br /&gt;
: Optional features in MIDAS can be explicitly disabled if desired when making MIDAS using the NO_xxx feature (NO_ROOT,NO_MYSQL,NO_ODBC,NO_SQLITE,NO_MSCB), e.g. &amp;quot;make NO_ROOT=1&amp;quot; to disable ROOT. These NO_xxx Makefile variables are only used to control autodetection.&lt;br /&gt;
&lt;br /&gt;
;NOTE 2&lt;br /&gt;
: Since June 2019 the mxml and mscb packages are submodules of the midas package, so no need to clone them separately. If you have an existing clone of midas but not yet the submodules, you need&lt;br /&gt;
&lt;br /&gt;
 $ git submodule update --init --recursive&lt;br /&gt;
&lt;br /&gt;
: To update both midas and the submodules, you need&lt;br /&gt;
&lt;br /&gt;
 $ git pull --recurse-submodules&lt;br /&gt;
&lt;br /&gt;
== Install ROOTANA ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
* cd rootana&lt;br /&gt;
* make&lt;br /&gt;
&lt;br /&gt;
== Install ROODY ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/tmidas/roody&lt;br /&gt;
* cd roody&lt;br /&gt;
* make&lt;br /&gt;
* $HOME/packages/roody/bin/roody, run the program&lt;br /&gt;
&lt;br /&gt;
== Install additional additional packages ==&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/ttriumfdaq/vme&lt;br /&gt;
* git clone https://bitbucket.org/ttriumfdaq/frontends&lt;br /&gt;
&lt;br /&gt;
== Build special versions of MIDAS ==&lt;br /&gt;
&lt;br /&gt;
Build special versions of MIDAS for the case when some MIDAS programs, such as VME frontends, will run on a different computer that may have a different flavour of operating system, i.e. 32-bit linux or an older version of Scientific Linux.&lt;br /&gt;
&lt;br /&gt;
* login to the computer where the frontends will run and:&lt;br /&gt;
* if it is a 32-bit linux: cd $HOME/packages/midas; make linux32&lt;br /&gt;
* if it is a 64-bit linux: cd $HOME/packages/midas; make linux64&lt;br /&gt;
&lt;br /&gt;
* login to the host computer to cross-compile ARM code:&lt;br /&gt;
* if it is an ARM linux: cd $HOME/packages/midas; make linuxarm # may need to install ARM cross compilers&lt;br /&gt;
&lt;br /&gt;
== Prepare VME hardware ==&lt;br /&gt;
&lt;br /&gt;
Hardware check list:&lt;br /&gt;
* VME crate&lt;br /&gt;
* VME processor (supported are V77xx, V7805, V7865)&lt;br /&gt;
* On all VME modules, set the VME address jumpers as described here: http://daq-plone.triumf.ca/SM/docs/local/vme_jumpers&lt;br /&gt;
* run vmescan to confirm correct VME addresses&lt;br /&gt;
** cd $HOME/packages&lt;br /&gt;
** svn checkout https://ladd00.triumf.ca/svn/daqsvn/trunk/vme&lt;br /&gt;
** cd vme&lt;br /&gt;
** make&lt;br /&gt;
** ./vmescan.exe (or _gef.exe, depending on the VME driver in use)&lt;br /&gt;
&lt;br /&gt;
== Install Universe-II VME driver (V7648, V7750, V7805, V7851) ==&lt;br /&gt;
&lt;br /&gt;
* login as root (ssh root@localhost)&lt;br /&gt;
* follow instructions: https://www.triumf.info/wiki/DAQwiki/index.php/VME-CPU#V7648.2C_V7750.2C_V7805.2C_V7851_:_Setup_vme_universe_VME_drivers&lt;br /&gt;
* cd ~/packages/vme; vmescan.exe&lt;br /&gt;
&lt;br /&gt;
== Install Tsi-148 VME driver (V7865) ==&lt;br /&gt;
&lt;br /&gt;
* login as root (ssh root@localhost)&lt;br /&gt;
* follow instructions: https://www.triumf.info/wiki/DAQwiki/index.php/VME-CPU#V7865_and_XVB-602_:_Setup_gefvme.2Ftsi148_VME_drivers&lt;br /&gt;
* cd ~/packages/vme; vmescan_gef.exe&lt;br /&gt;
&lt;br /&gt;
== Setup the experiment environment ==&lt;br /&gt;
&lt;br /&gt;
* Decide which computer will host MIDAS (where MIDAS shared memory buffers will reside). &lt;br /&gt;
: This computer will run the [[mserver]], [[mlogger]] and [[mhttpd]] applications. (It is usually the machine where the MIDAS,ROOT etc. packages have been downloaded). It will be referred to as the host machine (localhost).&lt;br /&gt;
&lt;br /&gt;
The environment is slightly different depending on whether all programs run on the host machine, or whether some programs run on remote host(s) : &lt;br /&gt;
=== ALL programs run on localhost ===&lt;br /&gt;
:If all programs run on the host machine (localhost), it is not necessary to run [[mserver]]. [[Environment Variables#MIDAS_SERVER_HOST|MIDAS_SERVER_HOST]] will not be assigned (see example .cshrc [[#Prepare the user account|above]]).&lt;br /&gt;
&lt;br /&gt;
=== Some programs run on REMOTE host(s) ===&lt;br /&gt;
: &#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; &lt;br /&gt;
# Since August 2015 &#039;&#039;&#039;you must explicitly allow access for clients running on remote machines&#039;&#039;&#039;. To do this, follow the &#039;&#039;&#039;[[Security#MIDAS programs on remote machines|instructions here]]&#039;&#039;&#039;.&lt;br /&gt;
# The example code .cshrc ([[#Prepare the user account|see above]]) should be present on both host and remote machine(s). This will ensure that [[Environment Variables#MIDAS_SERVER_HOST|MIDAS_SERVER_HOST]] will NOT be set for the host machine (localhost), but on a remote machine, MIDAS_SERVER_HOST will be set to the MIDAS host machine. &lt;br /&gt;
# The client [[mserver]] must be started on the MIDAS host machine. Note that multiple experiments can run on the same host machine by starting several instances of [[mserver]] (one for each experiment) running with different ports (and .cshrc would be edited so that MIDAS_SERVER_HOST is set to the appropriate port for the experiment).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
On the host machine:&lt;br /&gt;
* mkdir $HOME/online&lt;br /&gt;
* cd $HOME/online&lt;br /&gt;
* create directories for local programs, sources, elog and history: mkdir bin src elog history&lt;br /&gt;
* create data directory: mkdir -p /ladd/data1/t2kvme5/data; ln -s /ladd/data1/t2kvme5/data $HOME/online&lt;br /&gt;
* create the exptab file &amp;quot;$HOME/online/exptab&amp;quot; following the example below. The first entry (exptname) is the name if the DAQ system (MIDAS experiment name), the second entry (/home/USER/online) is the location of MIDAS shared memory buffers (by convention, $HOME/online), the third entry (kopio03) is your username.&lt;br /&gt;
&amp;lt;pre&amp;gt;exptname /home/kopio03/online kopio03&amp;lt;/pre&amp;gt;&lt;br /&gt;
* logout and login again for all changes to take effect&lt;br /&gt;
&lt;br /&gt;
== Setup experiment startup scripts ==&lt;br /&gt;
* login to the experiment host computer&lt;br /&gt;
* echo $MIDAS_SERVER_HOST ### to check correct value - should be blank&lt;br /&gt;
* create $HOME/online/bin/start_daq.sh, replacing XXX with the hostname of the machine running the experiment (and changing the mserver and mhttpd ports, as needed).&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 # start_daq.sh&lt;br /&gt;
 cd $HOME/online&lt;br /&gt;
 #&lt;br /&gt;
 case `hostname` in XXX*)&lt;br /&gt;
    echo &amp;quot;Good, we are on XXX!&amp;quot;&lt;br /&gt;
    ;;&lt;br /&gt;
 *)&lt;br /&gt;
    echo &amp;quot;The start_daq script should be executed on XXX&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
    ;;&lt;br /&gt;
 esac&lt;br /&gt;
 #&lt;br /&gt;
 odbedit -c clean&lt;br /&gt;
 #   start [[mhttpd]] on default port. (Mongoose https version - see [[mhttpd]] for other options)&lt;br /&gt;
 mhttpd  -D  -a localhost -a XXX.triumf.ca # optionally restrict access to specified hosts&lt;br /&gt;
 #&lt;br /&gt;
 #   start [[mserver]] on default port (use argument -p to use a different port) &lt;br /&gt;
 mserver -D   # access must now be specifically allowed - see [[#Setup the experiment environment|above]]&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;&lt;br /&gt;
 # OR ([[#NOTES|older MIDAS versions]])&lt;br /&gt;
 # mhttpd  -p 8081 -D -a localhost -a XXX.triumf.ca      # optionally restrict access to specified hosts&lt;br /&gt;
 # mserver -p 7071 -D -a localhost -a lxdragon01.triumf.ca -a lxdragon02.triumf.ca -a XXX.triumf.ca # optionally restrict access to specified hosts&lt;br /&gt;
 &amp;lt;/span&amp;gt;&lt;br /&gt;
 #&lt;br /&gt;
 mlogger -D&lt;br /&gt;
 #end file&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Run the MIDAS Web Server ==&lt;br /&gt;
Let&#039;s start the MIDAS webserver for the first time:&lt;br /&gt;
&lt;br /&gt;
Start [[mhttpd]] on the &#039;&#039;experiment host&#039;&#039; (localhost) like this:&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&amp;lt;/small&amp;gt;&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhttpd,INFO] ODB subtree /Runinfo corrected successfully&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17892:mongoose,ERROR] cannot find SSL certificate file &amp;quot;/home/agdaq/online/ssl_cert.pem&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17893:mongoose,ERROR] please create SSL certificate file: openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key; openssl x509 -req -days 365 -sha256 -in ssl_cert.csr -signkey ssl_cert.key -out ssl_cert.pem; cat ssl_cert.key &amp;gt;&amp;gt; ssl_cert.pem&lt;br /&gt;
 could not start the mongoose web server, see messages and midas.log, bye!&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a self-signed certificate suitable for initial testing by executing the command printed by mhttpd:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 [mhostpc] openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key; openssl x509 -req -days 365 -sha256 -in ssl_cert.csr -signkey ssl_cert.key -out ssl_cert.pem; cat ssl_cert.key &amp;gt;&amp;gt; ssl_cert.pem&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For production use, you should create a properly signed certificate, see [[Mhttpd#Create an SSL certificate|create your own SSL certificate]] or you should run mhttpd behind an SSL proxy.&lt;br /&gt;
&lt;br /&gt;
Run mhttpd again.&lt;br /&gt;
&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhttpd,INFO] ODB subtree /Runinfo corrected successfully&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot;&lt;br /&gt;
 Mongoose web server will use SSL certificate file &amp;quot;/home/johnfoo/packages/midas/ssl_cert.pem&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17633:mongoose,ERROR] mongoose web server cannot find password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot;&lt;br /&gt;
 [mhttpd,ERROR] [mhttpd.cxx:17634:mongoose,ERROR] please create password file: htdigest -c /home/johnfoo/online/htpasswd.txt Default midas&lt;br /&gt;
 could not start the mongoose web server, see messages and midas.log, bye!&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the password file by following the instructions printed by mhttpd. The http digest domain name is the experiment name, suggested default user name is &amp;quot;midas&amp;quot;. You will be asked to type in a password&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 [mhostpc] htdigest -c /home/johnfoo/online/htpasswd.txt exptname midas&lt;br /&gt;
 Adding password for midas in realm exptname.&lt;br /&gt;
 New password:&lt;br /&gt;
 Re-type new password:&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
It is a good idea to set the password file {{Filepath|path=htpasswd.txt}} readable and writable by owner only.&lt;br /&gt;
&lt;br /&gt;
Now restart  {{Utility|name=mhttpd}}&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&lt;br /&gt;
 Mongoose web server will listen on ports &amp;quot;8080r,8443s&amp;quot; **see note&lt;br /&gt;
 Mongoose web server will use SSL certificate file &amp;quot;/home/suz/packages/midas/ssl_cert.pem&amp;quot;&lt;br /&gt;
 Mongoose web server will use authentication realm &amp;quot;Default&amp;quot;, password file &amp;quot;./htpasswd.txt&amp;quot;&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Now point a web browser running on the same host computer (localhost) to https://localhost:8443&lt;br /&gt;
If the web browser is running on a different computer, go to URL of the form&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 https://mhostpc.triumf.ca:8443  (substitute your host machine name and domain for &amp;quot;mhostpc.triumf.ca&amp;quot;)&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
If you are using the default SSL certificate you will probably get a message: &amp;quot;This Connection is Untrusted&amp;quot;.  Click &amp;quot;I understand the risks&amp;quot; and add an exception. This is because the test certificate is self-signed. Then confirm an exception. &lt;br /&gt;
&lt;br /&gt;
If instead you get a &amp;quot;connection refused&amp;quot; error, the midas host pc may have the firewall enabled. To make a firewall exception for MIDAS, follow instructions here http://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29&lt;br /&gt;
&lt;br /&gt;
You should then see an authentication box asking you for the user name and password. The user name is &amp;quot;midas&amp;quot;. Enter the password you just created. The Midas [[Status Page]] should appear with multiple buttons for run control as well as equipment listing (no equipments will be listed as yet) and application listings. Please refer to [[mhttpd]] (the MIDAS Web-based Run Control utility) for further information. You can start and stop runs from the main status page, and use the [[ODB Page]] to access the database (ODB).&lt;br /&gt;
&lt;br /&gt;
; Note &lt;br /&gt;
: Default ports of 8080 and 8443 are used by [[mhttpd]]. If these ports are in use on your machine, start &amp;lt;span style=&amp;quot;color:darkcyan;font-style:italic&amp;quot;&amp;gt;mhttpd&amp;lt;/span&amp;gt; with alternative ports, e.g.&lt;br /&gt;
       &amp;lt;small&amp;gt;[mhostpc] mhttpd --https 8448 --http 8089&amp;lt;/small&amp;gt;&lt;br /&gt;
: or see [[Mhttpd#Usage]] to change the default ports.&lt;br /&gt;
&lt;br /&gt;
== Setup experiment database (ODB) ==&lt;br /&gt;
&lt;br /&gt;
* run $HOME/online/bin/start_daq.sh&lt;br /&gt;
&lt;br /&gt;
* odbedit, run these commands: (replace user names and directory names)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set &amp;quot;/Logger/Message file&amp;quot; &amp;quot;/home/kopio03/online/midas.log&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Data Dir&amp;quot;     &amp;quot;/home/kopio03/online/data&amp;quot;&lt;br /&gt;
create STRING &amp;quot;/Logger/History dir&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/History dir&amp;quot;  &amp;quot;/home/kopio03/online/history&amp;quot;&lt;br /&gt;
create STRING &amp;quot;/Logger/Elog dir&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Elog dir&amp;quot;     &amp;quot;/home/kopio03/online/elog&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/ODB dump file&amp;quot; &amp;quot;/home/kopio03/online/history/run%05d.xml&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/ODB dump&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Filename&amp;quot; &amp;quot;run%05dsub%03d.mid.gz&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Subrun byte limit&amp;quot; &amp;quot;1000000000&amp;quot;&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/Compression&amp;quot;   1&lt;br /&gt;
set &amp;quot;/Logger/Channels/0/Settings/ODB Dump&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/Logger/Required&amp;quot; y&lt;br /&gt;
set &amp;quot;/Programs/Logger/Start command&amp;quot; &amp;quot;mlogger -D&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/fevme/Required&amp;quot; &amp;quot;y&amp;quot;&lt;br /&gt;
set &amp;quot;/Programs/fevme/Start command&amp;quot; &amp;quot;ssh -n lxdaq09 $HOME/online/src/fevme_gef.exe -O&amp;quot;&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* open web browser e.g. firefox.&lt;br /&gt;
* go to the midas status page at https://localhost:8443  (default port). &lt;br /&gt;
** if running [[mhttpd]] with Mongoose HTTPS/OpenSSL (the default) for the first time, you will need to create a password file. Follow the instructions (see [[mhttpd#HTTPS/SSL server (Mongoose)]] for details).&lt;br /&gt;
** For other options (i.e. HTTPS/SSL proxy) see [[#Secure MIDAS and ELOG Web access]] &lt;br /&gt;
*&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;OR open the midas status page at http://localhost:8081 ([[#NOTES|older MIDAS versions]])&lt;br /&gt;
* midas status page will show most stuff &amp;quot;red&amp;quot; as nothing is running yet&lt;br /&gt;
* DON&#039;T DO THIS YET run ./fevme.exe (on the computer with the VME interface, could be different from computer hosting the experiment), observe that corresponding equipments have been created&lt;br /&gt;
* save the url bookmark to the &amp;quot;personal toolbar&amp;quot;&lt;br /&gt;
* go to the Programs page, stop mlogger, stop fevme, start mlogger, start fevme&lt;br /&gt;
* go to the Status page, start run, stop run&lt;br /&gt;
* go back to the Status page, everything should be green&lt;br /&gt;
* start a run&lt;br /&gt;
* send signals to the ADC gate&lt;br /&gt;
* you should be getting events&lt;br /&gt;
* to look at data, proceed with setting up the [[ROOTANA|ROOT Analyzer]].&lt;br /&gt;
&lt;br /&gt;
== Start DAQ programs at boot time ==&lt;br /&gt;
&lt;br /&gt;
* add this to /etc/rc.local (replace username and location of the start_daq script)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
su - alpha -c /home/alpha/online/bin/start_daq.sh&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setup local software version control ==&lt;br /&gt;
&lt;br /&gt;
Version control for experiment source code is setup using &amp;quot;git&amp;quot; (http://git-scm.com/)&lt;br /&gt;
&lt;br /&gt;
* cd $HOME/online&lt;br /&gt;
* git init&lt;br /&gt;
* git add exptab&lt;br /&gt;
* git add bin/start_daq.sh&lt;br /&gt;
* git add .gitignore ### contents can be&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
*~&lt;br /&gt;
*.o&lt;br /&gt;
*.exe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* git add src/Makefile src/*.cxx ...&lt;br /&gt;
* git commit -a&lt;br /&gt;
&lt;br /&gt;
== Adjust MIDAS buffer sizes ==&lt;br /&gt;
&lt;br /&gt;
Default MIDAS SYSTEM buffer size is 8 Mbytes, fairly small for high-data-rate experiments. The rule of thumb is to have at least a few seconds worth of buffer space available. For example, if event size is 10 Kbytes and the event rate is 1 kHz, data rate is 10*10^3*1*10^3 = 10 Mbytes/sec. To buffer 10 seconds of data we need 100 Mbytes of buffer space.&lt;br /&gt;
&lt;br /&gt;
To resize the MIDAS event buffers (SYSTEM, etc) do this:&lt;br /&gt;
* stop all frontends, stop mlogger&lt;br /&gt;
* start odbedit:&lt;br /&gt;
** cd &amp;quot;/Experiment/Buffer sizes&amp;quot;&lt;br /&gt;
** set SYSTEM 100000000&lt;br /&gt;
* run &amp;quot;mdump -z SYSTEM&amp;quot;&lt;br /&gt;
* if mdump complains about the size of .SYSTEM.SHM, remove it, try again.&lt;br /&gt;
* ls -l /dev/shm ### to observe that the size of shared memory is correct&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Secure MIDAS and ELOG Web access  ==&lt;br /&gt;
In versions prior to May 2015, the default web access to MIDAS and ELOG uses the &amp;quot;http:&amp;quot; protocol which is insecure. In this case, all information is transmitted as clear text meaning that secret, confidential and sensitive information (such as the MIDAS and ELOG passwords and usernames) can be stolen &amp;quot;easily&amp;quot;. This means that even &amp;quot;password protected&amp;quot; MIDAS and ELOG pages are not really protected if accessed using the &amp;quot;http&amp;quot; method. &lt;br /&gt;
 &lt;br /&gt;
Better security for HTTP is gained by using a password protected &#039;&#039;&#039;SSL (https) proxy&#039;&#039;&#039;. (It does not provide absolute security because of remaining problems with the security of SSL certificates, security of passwords, etc). Setting up an SSL (https) proxy is described [[#Setting up an HTTP proxy|below]].&lt;br /&gt;
&lt;br /&gt;
Since May 2015, an &#039;&#039;alternative secure option&#039;&#039; to setting up an HTTP proxy is available to users of MIDAS. Recent versions of elogd (ELOG) do support SSL https:// connections, and [[#mhttpd with HTTPS/SSL server (Mongoose)]] is now available.  This option is the default, and provides a similar level of security to an HTTP proxy. &lt;br /&gt;
&lt;br /&gt;
See [[Security#Web Access]] for a comparison of these two secure options.&lt;br /&gt;
  &lt;br /&gt;
=== mhttpd with HTTPS/SSL server (Mongoose) ===&lt;br /&gt;
&lt;br /&gt;
Since May 2015 the MIDAS web server [[mhttpd]] is explicitly linked with OpenSSL to provide secure HTTPS connections via the [https://bitbucket.org/tmidas/midas/src/ecb9a8537448a8a43f7f9a2bfdb82e578208cde3/doc/mongoose/?at=develop Mongoose] web server (see [[mhttpd]]). With this version, default web access to MIDAS uses the &amp;quot;https&amp;quot; protocol. Web access to {{Utility|name=mhttpd}} can be restricted by using the  &amp;quot;-a hostname&amp;quot; switch of [[mhttpd]]. The first time {{Utility|name=mhttpd}} is run, a password file must be created. An SSL certificate is also required. See [[mhttpd#HTTPS/SSL server (Mongoose)|HTTPS/SSL server (Mongoose)]] for instructions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== mhttpd using an HTTPS/SSL proxy ===&lt;br /&gt;
&lt;br /&gt;
THESE INSTRUCTIONS ARE WRONG, DO NOT DO THIS. See instead the [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog TRIUMF DAQ site].&lt;br /&gt;
&lt;br /&gt;
An [[#Setting up an HTTP proxy|HTTP proxy]] must be set up. This is the only way of securing older version of [[mhttpd]] (pre August 2015). Older versions of mhttpd are started using the -p port option  e.g.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt; mhttpd  -D -p 8080  &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run a new version of mhttpd using an HTTP proxy, use the options provided to run the old (non-Mongoose) webserver on a given port, i.e.&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;  mhttpd --oldserver 8080 --nomg   -D  &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using an SSL proxy, only access from the SSL proxy (and maybe some special trusted machines) should be permitted. &lt;br /&gt;
This is done using the &amp;quot;-a hostname&amp;quot; switch of [[mhttpd]]. Normally there will be only &amp;quot;-a localhost&amp;quot; switch, enabling access only for the local machine (where the SSL proxy is running). Additional &amp;quot;-a hostname&amp;quot; switches enable access from listed local machines. No &amp;quot;-a xxx&amp;quot; enables access from everywhere (defeating the purpose of the SSL proxy, unless access controls are enforced elsewhere, i.e. by a site firewall or by local firewall rules).&lt;br /&gt;
&lt;br /&gt;
== Setting up an HTTP proxy ==&lt;br /&gt;
In this example, we use APACHE HTTPD to password-protect a typical midas/mhttpd and elog installation.&lt;br /&gt;
&lt;br /&gt;
In this configuration, one uses the Linux stock httpd that accepts encrypted https:// connections and forwards them to mhttpd and elogd. Instead of (or in addition to) using mhttpd and elogd passwords, one configures password protection in httpd via the regular apache httpd password mechanisms (htpasswd, etc).&lt;br /&gt;
&lt;br /&gt;
Recent versions of elogd do support SSL https:// connections, but if one is running an SSL proxy for anyway, it is simpler to run both through the same SSL proxy using the same SSL host certificate and the same httpd password file.&lt;br /&gt;
&lt;br /&gt;
=== Restricting http: access to elogd ===&lt;br /&gt;
;Note&lt;br /&gt;
:Recent versions of elogd do support SSL https:// connections. The following information is for those using an HTTP proxy (see above).&lt;br /&gt;
&lt;br /&gt;
For elogd, this is done using the &amp;quot;-n localhost&amp;quot; switch with enables only access from the same machine if present, or access from anywhere is absent (defeating the purpose of the SSL proxy, unless access controls are enforced elsewhere).&lt;br /&gt;
&lt;br /&gt;
(It is recommended to run elogd from the same user as the main daq user and to keep elogd.cfg and all logbooks in the home directory of this user, where they are captured by the normal site backup system)&lt;br /&gt;
&lt;br /&gt;
== Install standalone elog ==&lt;br /&gt;
&lt;br /&gt;
* login into the user account that will run the elog&lt;br /&gt;
* cd $HOME/packages&lt;br /&gt;
* git clone https://bitbucket.org/ritt/elog&lt;br /&gt;
* cd elog&lt;br /&gt;
* make&lt;br /&gt;
* create new file start_elogd with this contents:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
killall elogd&lt;br /&gt;
sleep 1&lt;br /&gt;
killall -KILL elogd&lt;br /&gt;
sleep 1&lt;br /&gt;
$HOME/packages/elog/elogd -n localhost -x -c $HOME/packages/elog/elogd.cfg -p 8082 -D&lt;br /&gt;
&lt;br /&gt;
#end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* chmod a+x start_elogd&lt;br /&gt;
* edit elogd.cfg to read:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[global]&lt;br /&gt;
port = 8082&lt;br /&gt;
SMTP host = smtp.triumf.ca&lt;br /&gt;
URL = https://titan00.triumf.ca/elog/&lt;br /&gt;
&lt;br /&gt;
Reverse sort = 1&lt;br /&gt;
Display Mode = full&lt;br /&gt;
&lt;br /&gt;
#List Menu commands = New, Find, Admin, Help&lt;br /&gt;
#Menu commands = New, Edit, Reply, Find, Duplicate, Help&lt;br /&gt;
&lt;br /&gt;
Entries Per Page = 30&lt;br /&gt;
Supress Email on edit = 1&lt;br /&gt;
Default encoding = 1&lt;br /&gt;
Page title = TITAN ELOG&lt;br /&gt;
Resolve host names = 1&lt;br /&gt;
&lt;br /&gt;
Logfile = /home/titan/packages/elog/elogd.log&lt;br /&gt;
#Logging level = 3&lt;br /&gt;
&lt;br /&gt;
[midas]&lt;br /&gt;
&lt;br /&gt;
List page Title = T2K M11 MIDAS ELOG&lt;br /&gt;
Comment = T2K M11 MIDAS ELOG&lt;br /&gt;
Page Title = T2K M11 MIDAS ELOG&lt;br /&gt;
RSS Title = [$logbook - $type - $system] $subject, posted by $author&lt;br /&gt;
&lt;br /&gt;
Attributes = Author, Subject, Run, Type, System&lt;br /&gt;
Show Attributes Edit = Run, Author, Subject, Type, System&lt;br /&gt;
Required Attributes = Author, Type, System, Subject&lt;br /&gt;
&lt;br /&gt;
Options Type = Routine, Reply, Shift Summary, Modification, Question, Info, Problem&lt;br /&gt;
Options System = General, DAQ, Beamline&lt;br /&gt;
&lt;br /&gt;
Preset Run = $shell(MIDASSYS=. /home/t2km11/packages/midas/linux/bin/odbedit -d Runinfo -c &#039;ls -v \&amp;quot;run number\&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
Preset On Reply Type = Reply&lt;br /&gt;
Preset On Reply Run = $shell(MIDASSYS=. /home/t2km11/packages/midas/linux/bin/odbedit -d Runinfo -c &#039;ls -v \&amp;quot;run number\&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
List Display = Date, Subject, Type, System, Author, ID&lt;br /&gt;
Quick Filter = Date, Type, ID&lt;br /&gt;
&lt;br /&gt;
Remove on reply = Author&lt;br /&gt;
Quote on reply = 1&lt;br /&gt;
&lt;br /&gt;
Use lock = 1&lt;br /&gt;
&lt;br /&gt;
************* Email Functionality ****************&lt;br /&gt;
&lt;br /&gt;
Use Email Subject = [T2KM11 - $System] $Subject&lt;br /&gt;
Omit Email To = 1&lt;br /&gt;
&lt;br /&gt;
Email System General = xxx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* ./start_elogd &amp;amp;&lt;br /&gt;
* firefox http://localhost:8082 # hould show the elog message index&lt;br /&gt;
&lt;br /&gt;
To start elogd automatically when the machine is rebooted, login as root and&lt;br /&gt;
* add this text to /etc/rc.local:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
su - titan -c &amp;quot;/home/titan/packages/elog/start_elogd&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* chmod a+x /etc/rc.local&lt;br /&gt;
* systemctl start rc-local&lt;br /&gt;
&lt;br /&gt;
To import elog entries from the mhttpd elog, do this:&lt;br /&gt;
&lt;br /&gt;
* cd ~/packages/elog/logbooks&lt;br /&gt;
* ln -s /home/t2km11/online/elog midas&lt;br /&gt;
* cd midas&lt;br /&gt;
* ~/packages/elog/elconv)&lt;br /&gt;
&lt;br /&gt;
== Install https proxy ==&lt;br /&gt;
&lt;br /&gt;
THESE INSTRUCTIONS ARE OBSOLETE, INSTEAD, &lt;br /&gt;
* GO HERE: https://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Configure_HTTPS_server_.28CentOS7.29&lt;br /&gt;
* AND GO HERE: https://midas.triumf.ca/MidasWiki/index.php/Quickstart_Linux#Run_the_MIDAS_Web_Server&lt;br /&gt;
&lt;br /&gt;
FOLLOWING INSTRUCTIONS ARE OBSOLETE...&lt;br /&gt;
&lt;br /&gt;
* login as root to the https proxy machine&lt;br /&gt;
* cd ~root&lt;br /&gt;
* yum install mod_ssl&lt;br /&gt;
* yum install crypto-utils # see http://www.triumf.info/wiki/DAQwiki/index.php/SLinstall#Enable_monitoring_of_HTTPS_certificates&lt;br /&gt;
* create a certificate request (replace ladd09 with your hostname): openssl req -new -nodes -newkey rsa:2048 -sha256 -out ladd09.csr -keyout ladd09.key (answer: CA, BC, Vancouver, TRIUMF, DAQ, ladd09.triumf.ca, email@email.com&lt;br /&gt;
* sign it by TRIUMF:&lt;br /&gt;
** mail -s &amp;quot;Certificate request&amp;quot; yourself@email.com &amp;amp;lt; ladd09.csr&lt;br /&gt;
** forward this request to Andrew Daviel&lt;br /&gt;
** he will email the signed crt file, copy it to this system as ladd09.crt&lt;br /&gt;
* sign it yourself: openssl x509 -req -days 365 -sha256 -in ladd09.csr -signkey ladd09.key -out ladd09.crt&lt;br /&gt;
* (if the certificate expires, renew it by signing it again)&lt;br /&gt;
* Additional commands for working with certificates:&lt;br /&gt;
** explore the private key: openssl pkey -in ladd09.key -text -noout&lt;br /&gt;
** explore the certificate request: openssl req -in ladd00.csr -text -noout&lt;br /&gt;
** explore the certificate: openssl x509 -in ladd09.crt -noout -text&lt;br /&gt;
* move certificate files to proper system locations:&lt;br /&gt;
* mv ladd09.key  /etc/pki/tls/private/&lt;br /&gt;
* mv ladd09.crt /etc/pki/tls/certs/&lt;br /&gt;
* if selinux is enabled, do this:&lt;br /&gt;
** restorecon -Rv /etc/pki/tls/certs/&lt;br /&gt;
** restorecon -Rv /etc/pki/tls/private/&lt;br /&gt;
** /usr/sbin/setsebool -P httpd_can_network_connect 1&lt;br /&gt;
* open /etc/httpd/conf.d/ssl.conf in a text editor, go to the very bottom and right before the &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; entry, add following text:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SSLCertificateFile /etc/pki/tls/certs/ladd09.crt &lt;br /&gt;
SSLCertificateKeyFile /etc/pki/tls/private/ladd09.key &lt;br /&gt;
&lt;br /&gt;
ProxyPass /elog/ http://localhost:8082/ retry=1&lt;br /&gt;
ProxyPass /      http://localhost:8080/ retry=1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Location /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SSLRequireSSL&lt;br /&gt;
AuthType Basic&lt;br /&gt;
AuthName &amp;quot;password protected site&amp;quot;&lt;br /&gt;
Require valid-user&lt;br /&gt;
&lt;br /&gt;
# create password file: touch /etc/httpd/htpasswd&lt;br /&gt;
# to add new user or change password: htpasswd /etc/httpd/htpasswd username&lt;br /&gt;
AuthUserFile /etc/httpd/htpasswd&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/Location&amp;gt;&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* comment out duplicate &amp;quot;SSLCertificateFile&amp;quot; and &amp;quot;SSLCertificateKeyFile&amp;quot; elsewhere in the file&lt;br /&gt;
* (optionally) If you got a certificate that is signed by DigiCert or RapidSSL then you&#039;ll need to add a line specifying the certificate chain file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
SSLCertificateChainFile /etc/pki/tls/certs/DigiCertCA.crt&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* touch /etc/httpd/htpasswd&lt;br /&gt;
* htpasswd /etc/httpd/htpasswd midas # enter password midas&lt;br /&gt;
* chkconfig httpd on&lt;br /&gt;
* service httpd restart&lt;br /&gt;
* firewall-cmd --add-port=443/tcp --permanent&lt;br /&gt;
* firewall-cmd --reload&lt;br /&gt;
* firewall-cmd --list-all&lt;br /&gt;
* test it&lt;br /&gt;
** test the SSL proxy: https://host/ should yield the midas status page, https://host/elog/ should yield the elog message index&lt;br /&gt;
* in ODB, set &amp;quot;/Elog/URL&amp;quot; to &amp;quot;https://host/elog/&amp;quot;&lt;br /&gt;
* now from the midas status page, the &amp;quot;Elog&amp;quot; button should take us to the https Elog URL&lt;br /&gt;
&lt;br /&gt;
In needed, enable user directories: https://blah/~user in ~user/public_html&lt;br /&gt;
&lt;br /&gt;
* edit /etc/httpd/conf.d/userdir.conf, replace &amp;quot;UserDir disabled&amp;quot; with &amp;quot;UserDir enabled&amp;quot;&lt;br /&gt;
* setsebool -P httpd_enable_homedirs true&lt;br /&gt;
* systemctl restart httpd&lt;br /&gt;
&lt;br /&gt;
== Setup the history mhttpd for faster access to history plots ==&lt;br /&gt;
When running an SSL proxy,&lt;br /&gt;
* start the main mhttpd (&amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;orange&amp;lt;/span&amp;gt; command for old mhttpd, &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;green&amp;lt;/span&amp;gt; for new mhttpd with Mongoose(post August2015):&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8071 -D&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D --oldserver 8071 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* start the history mhttpd&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt; &amp;quot;mhttpd -p 8072 -D -H&amp;quot;&amp;lt;/span&amp;gt; or&lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D -H --oldserver 8072 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
* set ODB /History/URL to &amp;quot;http://alphacpc09.cern.ch:8072/HS/&amp;quot;&lt;br /&gt;
* open the MIDAS status page&lt;br /&gt;
* go to the history section, try to open any history plot, observe that the history plot gif image loads correctly, inspect it&#039;s URL (use &amp;quot;copy image URL&amp;quot; or &amp;quot;view source&amp;quot;, etc), it should point to port 8072 causing connection to the history mhttpd.&lt;br /&gt;
* continue with these instructions to setup history mhttpd access through an SSL proxy:&lt;br /&gt;
* setup SSL proxy access (required mod_proxy_html)&lt;br /&gt;
** login as root to the SSL proxy machine&lt;br /&gt;
** on SL5, install the missing mod_proxy_html httpd module:&lt;br /&gt;
** yum install httpd-devel libxml2-devel&lt;br /&gt;
** wget http://apache.webthing.com/mod_proxy_html/mod_proxy_html.tar.bz2&lt;br /&gt;
** tar xjvf mod_proxy_html.tar.bz2 &lt;br /&gt;
** cd mod_proxy_html&lt;br /&gt;
** apxs -c -I. -I/usr/include/libxml2 -i mod_proxy_html.c &lt;br /&gt;
** apxs -c -I. -I/usr/include/libxml2 -i mod_xml2enc.c&lt;br /&gt;
** cd /etc/httpd/conf.d, add this to ssl.conf:&lt;br /&gt;
&lt;br /&gt;
;before the ProxyPass statements:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# proxy the MIDAS web servers  &lt;br /&gt;
LoadModule  xml2enc_module       modules/mod_xml2enc.so  &lt;br /&gt;
LoadModule  proxy_html_module    modules/mod_proxy_html.so  &lt;br /&gt;
ProxyHTMLLinks  a               href  &lt;br /&gt;
ProxyHTMLLinks  link            href  &lt;br /&gt;
ProxyHTMLLinks  img             src  &lt;br /&gt;
#ProxyHTMLEnable On  &lt;br /&gt;
ProxyRequests off  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
;after the ProxyPass statements:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ALPHA1 history access &lt;br /&gt;
ProxyPass /alpha1/history/   http://alphacpc09.cern.ch:8072/HS/  retry=1 &lt;br /&gt;
ProxyPass /alpha1/           http://alphacpc09.cern.ch:8071/     retry=1 &lt;br /&gt;
 &lt;br /&gt;
ProxyHTMLEnable On  &lt;br /&gt;
ProxyHTMLURLMap http://alphacpc09.cern.ch:8072/HS/ /alpha1/history/ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
;adjust:&lt;br /&gt;
*&amp;quot;alpha1&amp;quot; is the experiment name&lt;br /&gt;
*&amp;quot;alphacpc09.cern.ch&amp;quot; is the machine running mhttpd&lt;br /&gt;
*&amp;quot;8071&amp;quot; is the port number of the main mhttpd &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8071 -D&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D --oldserver 8071 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
* &amp;quot;8072&amp;quot; is the port number of the history mhttpd &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:orange&amp;quot;&amp;gt;&amp;quot;mhttpd -p 8072 -D -H&amp;quot; &amp;lt;/span&amp;gt;  or  &lt;br /&gt;
** &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt; &amp;quot;mhttpd  -D -H --oldserver 8072 --nomg&amp;quot; &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]] [[Category:Buffer]] [[Category:Driver]]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3600</id>
		<title>Setup MySQL database for MIDAS</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Setup_MySQL_database_for_MIDAS&amp;diff=3600"/>
		<updated>2026-02-03T01:37:26Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Setting up MySQL on Ubuntu 24.04 LTS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides instructions for setting up a MySQL database to use with the MIDAS history logging.&lt;br /&gt;
&lt;br /&gt;
Setting up the MySQL database is highly dependent on what OS and OS version you are using.  Most of the setup work is just MySQL related.  For this reason we provide below instructions for the MySQL database setup on a couple different OS.  You will probably need to modify these instructions for your OS.  Here&#039;s the some installation instructions:&lt;br /&gt;
&lt;br /&gt;
* [[#Setting up MySQL on Ubuntu 24.04 LTS | Setting up MySQL on Ubuntu 24.04 LTS ]]&lt;br /&gt;
* [[#Setting up MySQL using mariadb on macbook | Setting up MySQL using mariadb on macbook]]&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL on Ubuntu 24.04 LTS ==&lt;br /&gt;
&lt;br /&gt;
This instructions assume you have root privileges and install MySQL as ROOT.  &lt;br /&gt;
&lt;br /&gt;
=== Do these steps as root user ===&lt;br /&gt;
&lt;br /&gt;
Install the MySQL server software.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
apt install mysql-server&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will find mysql has started after installation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# service mysql status&lt;br /&gt;
mysql.service - MySQL Community Server&lt;br /&gt;
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)&lt;br /&gt;
     Active: active (running) since Fri 2025-04-25 15:12:58 PDT; 4s ago&lt;br /&gt;
    Process: 153129 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0&amp;gt;&lt;br /&gt;
   Main PID: 153137 (mysqld)&lt;br /&gt;
     Status: &amp;quot;Server is operational&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Default configuration only allows MySQL connections to localhost.  Good&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel# grep bind-add /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br /&gt;
bind-address		= 127.0.0.1&lt;br /&gt;
mysqlx-bind-address	= 127.0.0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login to MySQL as root and create the MySQL accounts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql -h localhost&lt;br /&gt;
...&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
mysql&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;CHANGE_THIS_PASSWORD!&#039;;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
mysql&amp;gt; flush privileges;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ATTENTION: change the account password listed above to something different!&lt;br /&gt;
&lt;br /&gt;
Check the socket to connect to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
root@mpmt-daq03:/home1/wheel#  grep sock /etc/mysql/my.cnf &lt;br /&gt;
# Port or socket location where to connect&lt;br /&gt;
socket = /run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Do these steps as the experiment user === &lt;br /&gt;
&lt;br /&gt;
Rebuild MIDAS with support for MySQL.  If this works correctly the build will notice MySQL is installed.  For instance, with cmake we will see&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- MIDAS: Found MySQL version 8.0.41&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to online directory and create files so MIDAS knows accounts to talk to ODB&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ cd ~/online&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_reader.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ emacs -nw mysql_writer.txt&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ more mysql_*.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_reader.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
::::::::::::::&lt;br /&gt;
mysql_writer.txt&lt;br /&gt;
::::::::::::::&lt;br /&gt;
database=history&lt;br /&gt;
socket=/run/mysqld/mysqld.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=CHANGE_THIS_PASSWORD!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, set the correct password in these files.&lt;br /&gt;
&lt;br /&gt;
Change the mlogger settings so we use the MySQL for the history logging:&lt;br /&gt;
* disable the previous history logger&lt;br /&gt;
* enable the MySQL history logging:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
set &amp;quot;/Logger/History/MYSQL/Active&amp;quot; y &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart the mlogger on the command line and see that some MySQL tables are created and columns added:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
testmysql@mpmt-daq03:~/online$ mlogger &lt;br /&gt;
[Logger,INFO] Per-variable history is enabled&lt;br /&gt;
[Logger,ERROR] [history_schema.cxx:1258:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[Logger,INFO] Adding SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;&lt;br /&gt;
[Logger,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;table_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;fluxgate0&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;fluxgate1&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;valvex&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;valvey&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
[Logger,INFO] Adding column &amp;quot;t5&amp;quot; to SQL table &amp;quot;myperiodicequipment_pydt&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Login directly to the MySQL database and make sure the data is actually being logged&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql&amp;gt; select _i_time,fluxgate0 from myperiodicequipment_pydt where _i_time &amp;lt;1745620795;&lt;br /&gt;
+------------+-----------+&lt;br /&gt;
| _i_time    | fluxgate0 |&lt;br /&gt;
+------------+-----------+&lt;br /&gt;
| 1745620782 |   6.20209 |&lt;br /&gt;
| 1745620783 |    6.3519 |&lt;br /&gt;
| 1745620784 |    6.5677 |&lt;br /&gt;
| 1745620785 |   7.81413 |&lt;br /&gt;
| 1745620786 |   5.41127 |&lt;br /&gt;
| 1745620787 |   7.31112 |&lt;br /&gt;
| 1745620788 |   6.14285 |&lt;br /&gt;
| 1745620789 |   7.20425 |&lt;br /&gt;
| 1745620790 |    6.9303 |&lt;br /&gt;
| 1745620791 |   7.08178 |&lt;br /&gt;
| 1745620792 |   7.44422 |&lt;br /&gt;
| 1745620794 |   5.32677 |&lt;br /&gt;
+------------+-----------+&lt;br /&gt;
12 rows in set (0.00 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart mhttpd and you will see the history plots starting to get data from MySQL database.&lt;br /&gt;
&lt;br /&gt;
=== Change database location ===&lt;br /&gt;
&lt;br /&gt;
To move the database to a different location on file do the following as root ([https://tecadmin.net/change-default-mysql-data-directory-in-linux/ source]): &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
systemctl stop mysql &lt;br /&gt;
cp -a /var/lib/mysql /new/data/directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then update the MySQL configuration file /etc/mysql/my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
...&lt;br /&gt;
datadir=/new/data/directory&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You will need to either (a) adjust your apparmor settings, or (b) fully [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#disable_apparmor disable apparmor]. &lt;br /&gt;
Finally, restart the server: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
systemctl start mysql &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can now delete the original database directory&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
rm -rf /var/lib/mysql&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setting up MySQL using mariadb on macbook == &lt;br /&gt;
&lt;br /&gt;
* install mariadb-10.4&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos:&lt;br /&gt;
sudo port install mariadb-10.4&lt;br /&gt;
ln -s ln -fs /opt/local/lib/mariadb-10.4/bin/mysql_config ~/bin/&lt;br /&gt;
mysql_config --version&lt;br /&gt;
10.4.13&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* rebuild midas, check the cmake finds the correct mysql: MIDAS: Found MySQL version 10.4.13&lt;br /&gt;
* create $HOME/.my.cnf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[mysqld]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
datadir=/Users/olchansk/mysql/db&lt;br /&gt;
pid-file=/Users/olchansk/mysql/mysqld.pid&lt;br /&gt;
&lt;br /&gt;
[client]&lt;br /&gt;
#port=3306&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* mkdir $HOME/mysql&lt;br /&gt;
* start mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
macos: /opt/local/lib/mariadb-10.4/bin/mysqld&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* configure the database: start the &amp;quot;mysql&amp;quot; utility (/opt/local/lib/mariadb-10.4/bin/mysql)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
NOTE: instructions thanks to Ben S.&lt;br /&gt;
NOTE: use some other passwords instead of the example &amp;quot;reader_password&amp;quot; and &amp;quot;writer_password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE DATABASE IF NOT EXISTS history;&lt;br /&gt;
Query OK, 1 row affected (0.003 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER history_reader@&#039;localhost&#039; IDENTIFIED BY &#039;reader_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.027 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT ON history.* TO history_reader@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.016 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; CREATE USER &#039;history_writer&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;writer_password&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.014 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; GRANT SELECT,INSERT,CREATE,ALTER,INDEX ON history.* TO &#039;history_writer&#039;@&#039;localhost&#039;;&lt;br /&gt;
Query OK, 0 rows affected (0.017 sec)&lt;br /&gt;
&lt;br /&gt;
MariaDB [(none)]&amp;gt; flush privileges;&lt;br /&gt;
Query OK, 0 rows affected (0.001 sec)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* try connecting to both users:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_reader -p ### should ask for reader password&lt;br /&gt;
/opt/local/lib/mariadb-10.4/bin/mysql -u history_writer -p ### should ask for writer password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* create midas config files:&lt;br /&gt;
** mysql_writer.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_writer&lt;br /&gt;
password=writer_password ### change this!!!&lt;br /&gt;
#buffer=1000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
** mysql_reader.txt&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#server=localhost&lt;br /&gt;
#port=xxx&lt;br /&gt;
database=history&lt;br /&gt;
socket=/Users/olchansk/mysql/mysql.sock&lt;br /&gt;
user=history_reader&lt;br /&gt;
password=reader_password ### change this!!!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* test MIDAS connection&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt&lt;br /&gt;
(there should be no errors printed)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* if desired, import midas history from .hst files:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mh2sql --mysql mysql_writer.txt *.hst&lt;br /&gt;
Reading 130813.hst&lt;br /&gt;
[mh2sql,ERROR] [history_schema.cxx:1165:Mysql::Prepare,ERROR] mysql_query(SELECT event_name, table_name, itimestamp FROM _history_index WHERE table_name!=&#039;&#039;;) error 1146 (Table &#039;history._history_index&#039; doesn&#039;t exist)&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;rpcexample_1596127680&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;event_name&amp;quot; to SQL table &amp;quot;_history_index&amp;quot;, status 1&lt;br /&gt;
...&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions&amp;quot;, status 311&lt;br /&gt;
[mh2sql,INFO] Adding SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;state&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
[mh2sql,INFO] Adding column &amp;quot;run_number&amp;quot; to SQL table &amp;quot;run_transitions_1596127681&amp;quot;, status 1&lt;br /&gt;
Reading 130815.hst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
** change ODB /Logger/History/MYSQL/Active to &amp;quot;y&amp;quot;, &amp;quot;mysql writer&amp;quot; and &amp;quot;mysql reader&amp;quot; to location of these files (leave the default values if these files are in the experiment directory).&lt;br /&gt;
* enable MYSQL history in mhttpd:&lt;br /&gt;
** change ODB /History/LoggerHistoryChannel to &amp;quot;MYSQL&amp;quot;&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Message_System&amp;diff=3591</id>
		<title>Message System</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Message_System&amp;diff=3591"/>
		<updated>2026-01-15T20:32:58Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
&amp;lt;div id=&amp;quot;midas.log&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
== MIDAS Log file ==&lt;br /&gt;
MIDAS provides a general MIDAS log file for recording system and user messages across the different components of the data acquisition clients. The default name of this file is &#039;&#039;&#039;&#039;&#039;midas.log&#039;&#039;&#039;&#039;&#039;. It is not necessary for [[mlogger]] to be running for the MIDAS message logging system to work. As soon as any MIDAS application is started, the MIDAS log file is produced.&lt;br /&gt;
The [[#Example MIDAS Log file|MIDAS log file]] contains system and user messages generated by any application connected to the given experiment. &lt;br /&gt;
&lt;br /&gt;
Note that MIDAS messages may alternatively be sent into the data stream for logging.&lt;br /&gt;
&lt;br /&gt;
== Viewing MIDAS messages ==&lt;br /&gt;
All the MIDAS messages can be found in &#039;&#039;&#039;&#039;&#039;midas.log&#039;&#039;&#039;&#039;&#039;.&lt;br /&gt;
More convenient is the [[mhttpd]] [[Message Page]] where the latest MIDAS messages are displayed. The very latest midas message can also be found on the [[mhttpd]] [[Status Page]].  Midas messages are also sent to any clients running in an xterm (e.g. [[odbedit]]).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;midasloglocation&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
== Location of the MIDAS log file midas.log ==&lt;br /&gt;
The location of this file is dependent on how the experiment has been setup, i.e.&lt;br /&gt;
&lt;br /&gt;
; with the [[/Logger ODB tree]] :&lt;br /&gt;
If the &amp;lt;span style=&amp;quot;color: purple;&amp;quot;&amp;gt;&#039;&#039;/Logger&#039;&#039;&amp;lt;/span&amp;gt; ODB tree exists (i.e. has been created by [[mlogger]]) &lt;br /&gt;
* The message file will be located in the defined directory specified by the key [[Keys in the ODB /Logger tree#Data dir|/Logger/Data dir]].&lt;br /&gt;
* The name of the message file may be changed using the ODB key [[Keys in the ODB /Logger tree#Message File|/Logger/Message File]].&lt;br /&gt;
&lt;br /&gt;
;without the [[/Logger ODB tree]] :&lt;br /&gt;
If the &amp;lt;span style=&amp;quot;color: purple;&amp;quot;&amp;gt;&#039;&#039;/Logger&#039;&#039;&amp;lt;/span&amp;gt;  ODB tree does NOT exist , i.e. the MIDAS standard logger [[mlogger]] is not being used, &lt;br /&gt;
* the location of the log file will be in the experiment-specific directory defined by either&lt;br /&gt;
** the Environment Variable named MIDAS_DIR , or if this not defined,&lt;br /&gt;
** the exptab file .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
== Generating messages for the MIDAS log ==&lt;br /&gt;
Any client can produce status or error messages to be sent to the [[#MIDAS Log file]] with a single call to &lt;br /&gt;
[http://ladd00.triumf.ca/~daqweb/doc/midas-devel/doc/html/group__msgfunctionc.html#gaac032ca2438c47466bfc9722de6746ea cm_msg()] using the MIDAS library, e.g.&lt;br /&gt;
&lt;br /&gt;
 status = db_find_key(hDB, 0, &amp;quot;/Equipment/Cycle_scalers/Settings/&amp;quot;,&amp;amp;hKey);&lt;br /&gt;
  if(status != DB_SUCCESS &amp;amp;&amp;amp; status != DB_NO_KEY)&lt;br /&gt;
    {&lt;br /&gt;
      cm_msg(MERROR, &amp;quot;begin_of_run&amp;quot;, &amp;quot;error accessing \&amp;quot;/Equipment/Cycle_scalers/Settings/\&amp;quot;  (%d)&amp;quot;,status);&lt;br /&gt;
      return status;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Depending on the [[#message types|message type]], these messages are forwarded to any other clients who may be available to receive these messages, as well as to the central MIDAS Log file&lt;br /&gt;
midas.log. &lt;br /&gt;
The message system is based on the [[Midas Core#The Buffer Manager|buffer manager]] scheme, but with a dedicated header to identify the type of message. A dedicated buffer (i.e. shared &lt;br /&gt;
memory) .SYSMSG.SHM is used to receive and distribute messages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;Message Macros&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Message Types ==&lt;br /&gt;
&lt;br /&gt;
The predefined &#039;&#039;&#039;MIDAS Message macros&#039;&#039;&#039; contained in the MIDAS library provide a list of defined messages types.&lt;br /&gt;
These Macros compact the 3 first arguments of the cm_msg() call. &lt;br /&gt;
The Macro replaces the type of message, the routine name and the line number in the C-code. See &lt;br /&gt;
[http://ladd00.triumf.ca/~daqweb/doc/midas-devel/doc/html/group__msgfunctionc.html#gaac032ca2438c47466bfc9722de6746ea example] in cm_msg().&lt;br /&gt;
&lt;br /&gt;
The available message types ( defined in midas.h ) for use with cm_msg() are:&lt;br /&gt;
&lt;br /&gt;
;MT_ERROR&lt;br /&gt;
:Error message, to be displayed in red&lt;br /&gt;
:&amp;lt;code&amp;gt;(MT_ERROR, __FILE__, __LINE__)&amp;lt;/code&amp;gt;&lt;br /&gt;
;MT_INFO    &lt;br /&gt;
:Info or status message&lt;br /&gt;
:&amp;lt;code&amp;gt;(MT_INFO, __FILE__, __LINE__)&amp;lt;/code&amp;gt;&lt;br /&gt;
;MT_DEBUG &lt;br /&gt;
:Only sent to SYSMSG buffer, not to midas.log file. Handy if you produce lots of message and don&#039;t want to flood the message file. Plus it does not change the timing of your app, since the SYSMSG buffer is much faster than writing to a file.&lt;br /&gt;
:&amp;lt;code&amp;gt;(MT_DEBUG, __FILE__, __LINE__)&amp;lt;/code&amp;gt;&lt;br /&gt;
;MT_USER&lt;br /&gt;
:Message generated interactively by a user, like in the chat window or via the odbedit &amp;quot;msg&amp;quot; command&lt;br /&gt;
:&amp;lt;code&amp;gt;(MT_USER, __FILE__, __LINE__)&amp;lt;/code&amp;gt;&lt;br /&gt;
;MT_LOG&lt;br /&gt;
:Messages with are only logged but not put into the SYSMSG buffer&lt;br /&gt;
:&amp;lt;code&amp;gt;(MT_LOG, __FILE__, __LINE__)&amp;lt;/code&amp;gt;&lt;br /&gt;
;MT_TALK&lt;br /&gt;
:Messages which should go through the speech synthesis in the browser and are &amp;quot;spoken&amp;quot;&lt;br /&gt;
:&amp;lt;code&amp;gt;(MT_TALK, __FILE__, __LINE__)&amp;lt;/code&amp;gt;&lt;br /&gt;
;MT_CALL&lt;br /&gt;
:Message which would be forwarded to the user via a messaging app (historically this was an actual analog telephone call via a modem)&lt;br /&gt;
:&amp;lt;code&amp;gt;(MT_CALL, __FILE__, __LINE__)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example MIDAS Log file ==&lt;br /&gt;
&lt;br /&gt;
 Fri Mar 24 10:48:40 2000 [CHAOS] Run 8362 started&lt;br /&gt;
 Fri Mar 24 10:48:40 2000 [Logger] Run #8362 started&lt;br /&gt;
 Fri Mar 24 10:55:04 2000 [Lazy_Tape] cni-043[10] (cp:383.6s) /dev/nst0/run08360.ybs 849.896MB file NEW&lt;br /&gt;
 Fri Mar 24 11:24:03 2000 [MStatus] Program MStatus on host umelba started&lt;br /&gt;
 Fri Mar 24 11:24:03 2000 [MStatus] Program MStatus on host umelba stopped&lt;br /&gt;
 Fri Mar 24 11:27:02 2000 [Logger] stopping run after having received 1200000 events&lt;br /&gt;
 Fri Mar 24 11:27:03 2000 [CHAOS] Run 8362 stopped&lt;br /&gt;
 Fri Mar 24 11:27:03 2000 [SUSI] saving info in run log&lt;br /&gt;
 Fri Mar 24 11:27:03 2000 [Logger] Run #8362 stopped&lt;br /&gt;
 Fri Mar 24 11:27:13 2000 [Logger] starting new run&lt;br /&gt;
 Fri Mar 24 11:27:14 2000 [CHAOS] Run 8363 started&lt;br /&gt;
 Fri Mar 24 11:27:14 2000 [CHAOS] odb_access_file -I- /Equipment/kos_trigger/Dump not found&lt;br /&gt;
 Fri Mar 24 11:27:14 2000 [Logger] Run #8363 started&lt;br /&gt;
 Fri Mar 24 11:33:47 2000 [Lazy_Tape] cni-043[11] (cp:391.8s) /dev/nst0/run08361.ybs 850.209MB file NEW&lt;br /&gt;
 Fri Mar 24 11:42:35 2000 [CHAOS] Run 8363 stopped&lt;br /&gt;
 Fri Mar 24 11:42:40 2000 [SUSI] saving info in run log&lt;br /&gt;
 Fri Mar 24 11:42:41 2000 [ODBEdit] Run #8363 stopped&lt;br /&gt;
 Fri Mar 24 12:19:57 2000 [MChart] client [umelba.Triumf.CA]MChart failed watchdog test after 10 sec&lt;br /&gt;
 Fri Mar 24 12:19:57 2000 [MChart] Program MChart on host koslx0 stopped&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Messages]] [[Category:Macros]]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Alarm_System&amp;diff=3570</id>
		<title>Alarm System</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Alarm_System&amp;diff=3570"/>
		<updated>2025-10-31T17:16:50Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: Added messagebird voice calling instructions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
&amp;lt;div style=&amp;quot;column-count:3;-moz-column-count:3;-webkit-column-count:3&amp;quot;&amp;gt;&lt;br /&gt;
* [[/Alarms ODB tree]]&lt;br /&gt;
* [[Alarms Page]]&lt;br /&gt;
* [[Mhttpd|mhttpd MIDAS web server]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
MIDAS provides an alarm system, which by default is turned off. When the alarm system is [[/Alarms ODB tree#Alarm system active|activated]] and an alarm condition is detected, alarm messages are sent by the system which appear as an alarm banner on the [[Status Page|mhttpd status page]], and as a message on any windows running [[odbedit]] clients. The alarm system is flexible and can be extensively customized for each experiment&lt;br /&gt;
using the [[Alarms Page|mhttpd Alarms Page]] or [[odbedit]]. &lt;br /&gt;
&lt;br /&gt;
The alarm system is built-in and part of the main experiment scheduler. This means no separate task is necessary to benefit from the alarm system. Its setup and activation is done through the &#039;&#039;&#039;[[/Alarms ODB tree]]&#039;&#039;&#039;. The alarm system includes several other features such as sequencing and control of the experiment. The alarm capabilities are:&lt;br /&gt;
* Alarm setting on any ODB variable against a threshold parameter.&lt;br /&gt;
* Alarm triggered by evaluated condition&lt;br /&gt;
* Selection of Alarm check frequency&lt;br /&gt;
* Selection of Alarm trigger frequency&lt;br /&gt;
* Customization alarm scheme; under this scheme multiple choices of alarm type can be selected&lt;br /&gt;
* Selection of alarm message destination (to system message log or to elog)&lt;br /&gt;
* email or SMS alerts can be sent&lt;br /&gt;
* Alarm triggered when a Program is not running &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Implementation of the MIDAS Alarm System =&lt;br /&gt;
&lt;br /&gt;
The alarm system source code is [http://ladd00.triumf.ca/~daqweb/doc/midas-devel/doc/html/alarm_8c_source.html alarm.c].&lt;br /&gt;
Alarms are checked inside [http://ladd00.triumf.ca/~daqweb/doc/midas-devel/doc/html/group__alfunctioncode.html alarm.c::al_check()]. This function is called by cm_yield() every 10 seconds and by rpc_server_thread(), also every 10 seconds. For remote MIDAS clients, their al_check() issues an RPC_AL_CHECK RPC call into the MIDAS server utility [[mserver]], where rpc_server_dispatch() calls the local al_check(). As result, all alarm checks run inside a process directly attached to the local MIDAS shared memory (inside a local client or inside an mserver process for a remote client). Each and every MIDAS client runs the alarm checks. To prevent race conditions between different MIDAS clients, access to al_check() is serialized using the ALARM semaphore. Inside al_check(), alarms are triggered using &lt;br /&gt;
[http://ladd00.triumf.ca/~daqweb/doc/midas-devel/doc/html/group__alfunctioncode.html al_trigger_alarm()], which in turn calls al_trigger_class(). Inside al_trigger_class(), the alarm is recorded into an elog or into [[Message System|midas.log]] using cm_msg(MTALK).&lt;br /&gt;
&lt;br /&gt;
Special note should be made of the ODB setting [[/Alarms ODB tree#System message interval|system message interval]], which has a surprising effect - after an alarm is recorded into system messages (using cm_msg(MTALK)), no record is made of any subsequent alarms until the time interval set by this variable elapses. With default value of 60 seconds, after one alarm, no more alarms are recorded for 60 seconds. Also, because all the alarms are checked at the same time, &#039;&#039;&#039;only the first&#039;&#039;&#039; triggered alarm will be recorded.&lt;br /&gt;
&lt;br /&gt;
As of alarm.c rev 4683, {{Odbpath|path=/Alarms/System message interval}} is set to 0 ensures that every alarm is recorded into the [[Message System#MIDAS Log file|MIDAS log file]]. (In previous revisions, this setting may still miss some alarms).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;Alarm class&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
= Alarms structure =&lt;br /&gt;
The [[/Alarms ODB tree]] structure is split into 2 sections:&lt;br /&gt;
*&amp;quot;Alarms&amp;quot; which define the condition to be tested. The user can create as many [[/Alarms ODB tree#Alarms subtree|Alarms]] as desired, but each must be one of the four defined [[#Alarm Types|Alarm types]] .&lt;br /&gt;
*&amp;quot;Classes&amp;quot; which define the action to be taken when the alarm occurs. Two Classes (Alarm and Warning) are defined by default. The user can add more [[/Alarms ODB tree#Classes subtree|Classes]] as desired.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to make the system flexible, each alarm class may perform different actions when an alarm is given. For example, it may&lt;br /&gt;
* write a system message (see [[/Alarms ODB tree#Write System Message|Write System Message]])&lt;br /&gt;
* write to the elog (see [[/Alarms ODB tree#Write Elog Message|Write Elog Message]])&lt;br /&gt;
* stop the run (see [[/Alarms ODB tree#Stop run|Stop run]])&lt;br /&gt;
* spawn a detached script listed in the ODB variable [[/Alarms ODB tree#Execute command|Execute command]]. This feature is used when an Alarm triggers Email or SMS alerts (see [[#Alarm triggering Email or SMS alerts|example]]).&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Alarm Types =&lt;br /&gt;
&lt;br /&gt;
The four available Alarm Types are shown in Table 1. They are defined in [http://ladd00.triumf.ca/~daqweb/doc/midas-devel/html/midas_8h.html&amp;amp;nbsp midas.h]. The alarm type is entered into the [[/Alarms ODB tree#Type|Type]] key.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|  style=&amp;quot;text-align: left; width: 100%; background-color: white;&amp;quot; border=&amp;quot;3&amp;quot; cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;2&amp;quot;&lt;br /&gt;
|+ Table 1 : Defined Alarm Types&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; rowspan=&amp;quot;1&amp;quot; style=&amp;quot;vertical-align: top; background-color: lavender; font-weight: bold;&amp;quot; | Alarm Type&lt;br /&gt;
| colspan=&amp;quot;1&amp;quot; rowspan=&amp;quot;1&amp;quot; style=&amp;quot;vertical-align: top; background-color: lavender; font-weight: bold;&amp;quot; | INT value&lt;br /&gt;
| colspan=&amp;quot;1&amp;quot; rowspan=&amp;quot;1&amp;quot; style=&amp;quot;vertical-align: top; background-color: lavender; font-weight: bold;&amp;quot; | Explanation&lt;br /&gt;
&lt;br /&gt;
|-   &lt;br /&gt;
| colspan=&amp;quot;1&amp;quot; rowspan=&amp;quot;1&amp;quot;  style=&amp;quot;vertical-align: top; background-color: white; font-weight: bold;&amp;quot;  |Internal alarms&lt;br /&gt;
| colspan=&amp;quot;1&amp;quot; rowspan=&amp;quot;1&amp;quot;  style=&amp;quot;vertical-align: top; background-color: white; font-weight: normal;&amp;quot; | AT_INTERNAL&lt;br /&gt;
|1&lt;br /&gt;
|Trigger on internal (program) alarm setting through the use of the al_...() functions. &lt;br /&gt;
&lt;br /&gt;
|-   &lt;br /&gt;
| style=&amp;quot;vertical-align: top; background-color: white; font-weight: bold;&amp;quot; |Program alarms&lt;br /&gt;
|AT_PROGRAM&lt;br /&gt;
|2&lt;br /&gt;
|Triggered on condition of the state of the defined task (i.e. program not running)&lt;br /&gt;
&lt;br /&gt;
|-   &lt;br /&gt;
| style=&amp;quot;vertical-align: top; background-color: white; font-weight: bold;&amp;quot; |Evaluated alarms&lt;br /&gt;
|AT_EVALUATED&lt;br /&gt;
|3&lt;br /&gt;
|Triggered by ODB value on given arithmetical condition. &lt;br /&gt;
&lt;br /&gt;
|-   &lt;br /&gt;
| style=&amp;quot;vertical-align: top; background-color: white; font-weight: bold;&amp;quot; |Periodic alarms&lt;br /&gt;
|AT_PERIODIC&lt;br /&gt;
|4&lt;br /&gt;
|Triggered by timeout condition defined in the alarm setting. &lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Program Alarm ==&lt;br /&gt;
&lt;br /&gt;
Program (or rather &amp;quot;Program not running&amp;quot;) alarms, when enabled, warn the user when a program is not running.&lt;br /&gt;
&lt;br /&gt;
Program alarms are enabled by setting the ODB key [[/Programs ODB tree#Alarm class|/Programs/&amp;lt;client-name&amp;gt;/Alarm class]] to a valid Alarm class specified in the [[/Alarms ODB tree]]. The first time the alarm is triggered, an &amp;lt;span style=&amp;quot;color: purple; font-style:italic;&amp;quot;&amp;gt;/Alarms/Alarms/&amp;lt;client-name&amp;gt;&amp;lt;/span&amp;gt; subtree will be created automatically. The program alarm will not be visible in the [[Alarms Page]] until the alarm has triggered, and the subtree created.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
The alarm system periodically calls [http://ladd00.triumf.ca/~daqweb/doc/midas-devel/doc/html/group__alfunctioncode.html al_check()]. This causes every client listed in the {{Odbpath|path=/Programs}} ODB tree to be tested using [http://ladd00.triumf.ca/~daqweb/doc/midas-devel/doc/html/group__cmfunctionc.html cm_exist()] to see if it is running. If the client is not running, the time of first failure is recorded in the ODB key [[/Programs ODB tree#First failed|/Programs/&amp;lt;client-name&amp;gt;/First failed]].&lt;br /&gt;
&lt;br /&gt;
If the client has not been running for longer than the time set in ODB key [[/Programs ODB tree#Check interval|/Programs/&amp;lt;client-name&amp;gt;/Check interval]], a &amp;quot;Program not running&amp;quot; alarm is triggered (if enabled by [[/Programs ODB tree#Alarm class|Alarm class]]) and the program is restarted (if enabled by [[/Programs ODB tree#Auto restart|/Programs/&amp;lt;client-name&amp;gt;/Auto restart]] and a valid [[/Programs ODB tree#Start command|Start command]] is supplied).&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;not running&amp;quot; condition is tested every 10 seconds (each time al_check() is called), but the frequency of &#039;&#039;Program not running&#039;&#039; alarms can be reduced by increasing the value of the ODB key&lt;br /&gt;
[[/Programs ODB tree#Check interval|/Programs/&amp;lt;client-name&amp;gt;/Check interval]]&lt;br /&gt;
(default value 60 seconds). This can be useful if  [[/Alarms ODB tree#System message interval|System message interval]] in the specified alarm class subtree is set to zero.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Periodic Alarm ==&lt;br /&gt;
The periodic alarm is activated periodically according to the time in [[/Programs ODB tree#Check interval|/Programs/&amp;lt;client-name&amp;gt;/Check interval]]. An example of a periodic alarm is &amp;quot;Demo Periodic&amp;quot; in the  [[/Alarms ODB tree#Example|example]].&lt;br /&gt;
&lt;br /&gt;
== Evaluated Alarm  ==&lt;br /&gt;
&lt;br /&gt;
Evaluated alarms require an &#039;&#039;alarm condition&#039;&#039; which is entered into the ODB key [[/Alarms ODB tree#Condition|Condition]] in the  [[/Alarms ODB tree#&amp;lt;alarm_name&amp;gt; subtree|&amp;lt;alarm_name&amp;gt; subtree]].&lt;br /&gt;
The condition may be simply a &#039;&#039;&#039;comparison&#039;&#039;&#039; between any ODB variable and a threshold parameter, e.g.&lt;br /&gt;
&lt;br /&gt;
 /Runinfo/Run number &amp;gt; 100&lt;br /&gt;
or it may be an &#039;&#039;&#039;evaluated condition&#039;&#039;&#039;. One can write conditions like&lt;br /&gt;
&lt;br /&gt;
  /Equipment/HV/Variables/Input[*] &amp;gt; 100&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  /Equipment/HV/Variables/Input[2-3] &amp;gt; 100&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  /Equipment/HV/Variables/Input[1,4,5-8,10] &amp;gt; 100&lt;br /&gt;
&lt;br /&gt;
to check all or certain values from an array. A dash means a range including both indices. If one array element fulfills the alarm condition, the alarm is triggered. In addition, bit-wise alarm conditions are possible, e.g.&lt;br /&gt;
&lt;br /&gt;
  /Equipment/Environment/Variables/Input[0] &amp;amp; 8&lt;br /&gt;
The alarm is triggered if bit #3 is set in Input[0].&lt;br /&gt;
&lt;br /&gt;
The value of an evaluated alarm is computed using al_evaluate_condition() in [http://ladd00.triumf.ca/~daqweb/doc/midas-devel/html/alarm_8c_source.html alarm.c].&lt;br /&gt;
&lt;br /&gt;
Sometimes alarm trigger kind of accidentally on some analog input voltage if they are noise. In order to avoid this, the &amp;quot;Trigger count required&amp;quot; can be used. If this value contains a non-zero value of N, then the alarm system requires the alarm condition to be met N consecutive times until the alarm to be triggered.&lt;br /&gt;
&lt;br /&gt;
== Internal Alarm ==&lt;br /&gt;
These are triggered in a program using a call to &lt;br /&gt;
[https://daq.triumf.ca/~daqweb/doc/midas-devel/html/group__alfunctioncode.html al_trigger_alarm()]. See also description of al_trigger_alarm() sequence  [[#Implementation of the MIDAS Alarm System|above]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There is nothing surprising in these alarms. Each alarm is checked with a time period set by ODB key [[ /Alarms ODB tree#Check interval|Check interval]] in the [[/Alarms ODB tree]].&lt;br /&gt;
&lt;br /&gt;
= Alarm triggering Email or SMS alerts =&lt;br /&gt;
&lt;br /&gt;
It is possible to have the MIDAS alarm system send email or SMS alerts to cell phones when alarms are triggered. This can be configured by defining an ODB alarm on a critical ODB parameter, e.g.&lt;br /&gt;
&lt;br /&gt;
 /Alarms/Alarms/Liquid Level&lt;br /&gt;
 Active                   y&lt;br /&gt;
 Triggered                0 (0x0)&lt;br /&gt;
 Type                     3 (0x3)&lt;br /&gt;
 Check interval          60 (0x3C)&lt;br /&gt;
 Checked last    1227690148 (0x492D10A4)&lt;br /&gt;
 Trigger count            0 (0x0)&lt;br /&gt;
 Trigger count required   0 (0x0)&lt;br /&gt;
 Time triggered first    (empty)&lt;br /&gt;
 Time triggered last     (empty)&lt;br /&gt;
 Condition               /Equipment/Environment/Variables/Input[0] &amp;lt; 10&lt;br /&gt;
 Alarm Class             Level Alarm&lt;br /&gt;
 Alarm Message           Liquid Level is only %s&lt;br /&gt;
&lt;br /&gt;
In this example, the alarm triggers an alarm of class &amp;quot;Level Alarm&amp;quot;. This alarm class is defined as follows:&lt;br /&gt;
&lt;br /&gt;
 /Alarms/Classes/Level Alarm&lt;br /&gt;
 Write system message    y&lt;br /&gt;
 Write Elog message      n&lt;br /&gt;
 System message interval 600 (0x258)&lt;br /&gt;
 System message last     0 (0x0)&lt;br /&gt;
 Execute command         /home/midas/level_alarm &#039;%s&#039;&lt;br /&gt;
 Execute interval        1800 (0x708)&lt;br /&gt;
 Execute last            0 (0x0)&lt;br /&gt;
 Stop run                n&lt;br /&gt;
 Display BGColor         red&lt;br /&gt;
 Display FGColor         black&lt;br /&gt;
&lt;br /&gt;
The key here is to call a script &amp;quot;level_alarm&amp;quot;, which can send emails. Use something like:&lt;br /&gt;
&lt;br /&gt;
 #/bin/csh&lt;br /&gt;
 echo $1 | mail -s \&amp;quot;Level Alarm\&amp;quot; your.name@domain.edu&lt;br /&gt;
 odbedit -c &#039;msg 2 level_alarm \&amp;quot;Alarm was sent to your.name@domain.edu\&amp;quot;&#039;&lt;br /&gt;
&lt;br /&gt;
Ensure the shell script is executable (e.g., &amp;lt;code&amp;gt;chmod +x script.sh&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
The second command just generates a MIDAS system message for confirmation. Most cell phones (depends on the provider) have an email address. If you send an email there, it will be translated into a SMS message.&lt;br /&gt;
&lt;br /&gt;
The script file above can of course be more complicated. A perl script could be used that parses an address list, so other interested parties can register by adding his/her email address to that list. The script may also collects some other slow control variables (like pressure, temperature) and combine them into the SMS message.&lt;br /&gt;
&lt;br /&gt;
For very sensitive systems, having an alarm via SMS may not be sufficient, since the alarm system could be down (e.g. computer crash, network failure). In this case &#039;negative alarms&#039; can be used. For example, every 30 minutes the system may send an SMS with the current parameter values. If the expected message is not received, it may indicate that something in the MIDAS system is wrong.&lt;br /&gt;
&lt;br /&gt;
= Alarm triggering Slack notifications =&lt;br /&gt;
&lt;br /&gt;
A more modern way for notification is to use messengers apps such as Slack. To send alarms to Slack, do the following:&lt;br /&gt;
&lt;br /&gt;
* Go to https://api.slack.com/apps&lt;br /&gt;
* Create an App &amp;quot;MIDAS alarms&amp;quot;, select &amp;quot;From scratch&amp;quot;&lt;br /&gt;
* Name it &amp;quot;MIDAS alarm&amp;quot; or similar, select your workspace&lt;br /&gt;
* Click on &amp;quot;Add features and functionality&amp;quot;&lt;br /&gt;
* Select &amp;quot;Incoming Webhooks&amp;quot;&lt;br /&gt;
* Activate Incoming Webhooks&lt;br /&gt;
* Click on &amp;quot;Add New Webhook to Workspace&amp;quot;&lt;br /&gt;
* Select channel where alarms get posted, allow access&lt;br /&gt;
* Copy sample curl request and replace &amp;quot;Hello World&amp;quot; by &amp;quot;$1&amp;quot;, such as: &lt;br /&gt;
&lt;br /&gt;
 curl -X POST -H &#039;Content-type: application/json&#039; --data &amp;quot;{\&amp;quot;text\&amp;quot;:\&amp;quot;$1\&amp;quot;}&#039; https://hooks.slack.com/services/[xxx]/[yyy]/[zzz]&lt;br /&gt;
&lt;br /&gt;
(leave they keys xxx, yyy, zzz as shown on the web page).&lt;br /&gt;
&lt;br /&gt;
* Call the curl command from the alarm system by putting the above command under &amp;lt;code&amp;gt;/Alarms/Classes/All/Execute command&amp;lt;/code&amp;gt; into the ODB.&lt;br /&gt;
* Ensure the shell script is executable (e.g., &amp;lt;code&amp;gt;chmod +x script.sh&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
= Alarm triggering Telegram notifications =&lt;br /&gt;
&lt;br /&gt;
A telegram bot needs to be created to post Midas alarms into telegram channels.&lt;br /&gt;
&lt;br /&gt;
* Go to https://web.telegram.org and login by scanning the QR-code with the telegram app on your phone&lt;br /&gt;
* Go to https://t.me/botfather&lt;br /&gt;
* Click on &amp;quot;open in web&amp;quot;&lt;br /&gt;
* A chat window will open. &lt;br /&gt;
* Send &amp;quot;/newbot&amp;quot; into the chat and assign name and username to your bot&lt;br /&gt;
* At the end of the bot creation a access token will be displayed. Save that access token.&lt;br /&gt;
* Post &amp;quot;/mybots&amp;quot; into the chat&lt;br /&gt;
* Select the bot that was just created&lt;br /&gt;
* Click on &amp;quot;Bot settings&amp;quot;&lt;br /&gt;
* Click on &amp;quot;Allow Groups&amp;quot;&lt;br /&gt;
* Enable groups for the bot&lt;br /&gt;
* Click on &amp;quot;back to settings&amp;quot;&lt;br /&gt;
* Click on Channel Admin Rights&lt;br /&gt;
* Click on &amp;quot;Manage channel&amp;quot; (a checkmark should appear next to the text)&lt;br /&gt;
* Close this chat.&lt;br /&gt;
&lt;br /&gt;
* Add the created bot to a telegram group chat via searching for the bot name in &amp;quot;add members&amp;quot; (same as adding new People to the group)&lt;br /&gt;
* Now you need the chat_id of the same group chat. When you open the group chat in a webbrowser the URL should look like this https://web.telegram.org/a/#-1700000000 (where 1700000000 will be a different number for you)&lt;br /&gt;
* The group chat_id is then -1001700000000 (add -100 in front of the number in your URL)&lt;br /&gt;
* With the chat_id from above and the access token from the bot creation process you can post to the telegram group like this: (replace &amp;lt;chat_id&amp;gt; and &amp;lt;accessToken&amp;gt; with your numbers)&lt;br /&gt;
&lt;br /&gt;
  curl -s -X  POST &amp;quot;https://api.telegram.org/bot&amp;lt;accessToken&amp;gt;/sendMessage&amp;quot; -d chat_id=&amp;lt;chat_id&amp;gt; -d text=&amp;quot;🚨 Midas alarm triggered with message = $1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Create a shell script with this command&lt;br /&gt;
* Ensure the shell script is executable (e.g., &amp;lt;code&amp;gt;chmod +x script.sh&amp;lt;/code&amp;gt;)&lt;br /&gt;
* Call the shell script from the alarm system by putting &amp;lt;code&amp;gt;path/to/script.sh &#039;%1$s&#039;&amp;lt;/code&amp;gt; under &amp;lt;code&amp;gt;/Alarms/Classes/All/Execute command&amp;lt;/code&amp;gt; into the ODB.&lt;br /&gt;
* Should you want to post the same alarm to multiple systems you can just separate scripts in &amp;lt;code&amp;gt;/Alarms/Classes/All/Execute command&amp;lt;/code&amp;gt; with a semicolon &amp;lt;code&amp;gt;path/to/script.sh &#039;%1$s&#039;;path/to/script2.sh &#039;%1$s&#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Alarm triggering Mattermost notifications =&lt;br /&gt;
&lt;br /&gt;
First a mattermost bot needs to be created. To do this you need to be an Admin of the Team that the bot should post to.&lt;br /&gt;
&lt;br /&gt;
* In the drop down menu on the top left corner of the mattermost page click on &amp;quot;Integrations&amp;quot; (note: this field will be missing if you are not an Admin of the selected mattermost team) &lt;br /&gt;
* Select &amp;quot;Incoming Webhooks&amp;quot;&lt;br /&gt;
* Click on &amp;quot;Add Incoming Webhook&amp;quot;&lt;br /&gt;
* Give the bot a title and username (e.g. midasalarms) and select the channel to post to, click &amp;quot;save&amp;quot;&lt;br /&gt;
* Now a URL for the incoming webhook should be displayed (https://mattermost.gitlab.rlp.net/hooks/&amp;lt;token&amp;gt;). Copy that URL into the curl command in the following script:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   #!/bin/bash&lt;br /&gt;
   alarm_message=$1&lt;br /&gt;
   generate_post_data()&lt;br /&gt;
   {&lt;br /&gt;
     cat &amp;lt;&amp;lt;EOF&lt;br /&gt;
     {&lt;br /&gt;
     &amp;quot;text&amp;quot;: &amp;quot;@all Midas alarm triggered with message = $alarm_message&amp;quot;, &lt;br /&gt;
     &amp;quot;icon_emoji&amp;quot;:&amp;quot;:rotating_light:&amp;quot;, &lt;br /&gt;
     &amp;quot;username&amp;quot;:&amp;quot;Midas&amp;quot;}&lt;br /&gt;
   EOF&lt;br /&gt;
   }&lt;br /&gt;
   curl -i -X POST -H &#039;Content-Type: application/jsoni&#039; --data &amp;quot;$(generate_post_data)&amp;quot; https://mattermost.gitlab.rlp.net/hooks/&amp;lt;token&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Call the shell script from the alarm system by putting &amp;lt;code&amp;gt;path/to/script.sh &#039;%1$s&#039;&amp;lt;/code&amp;gt; under &amp;lt;code&amp;gt;/Alarms/Classes/All/Execute command&amp;lt;/code&amp;gt; into the ODB.&lt;br /&gt;
Ensure the shell script is executable (e.g., &amp;lt;code&amp;gt;chmod +x script.sh&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Alarm triggering MessageBird Voice Call =&lt;br /&gt;
&lt;br /&gt;
We will use a text-to-voice to read out MIDAS alarms in a phone call to shifters. The service is called bird (formerly messagebird). Note that bird hosts two platforms: &amp;quot;engagement&amp;quot; and &amp;quot;connectivity&amp;quot;. Each has its own API, documentation, and web interface. We will use the engagement platform. Be sure to look at the [https://docs.bird.com correct documentation].&lt;br /&gt;
&lt;br /&gt;
== MessageBird Setup == &lt;br /&gt;
&lt;br /&gt;
# Make an account: https://app.bird.com/ &lt;br /&gt;
# Add some funds to your main wallet: https://app.bird.com/settings/billing/overview/wallets/&lt;br /&gt;
# Buy a number. This number will be the where the call originates from, so you should pick something local to your area.  &lt;br /&gt;
## In the left-hand navigation side panel: &amp;quot;Developer&amp;quot; -&amp;gt; &amp;quot;Numbers&amp;quot; -&amp;gt; &amp;quot;Numbers &amp;amp; Senders&amp;quot;&lt;br /&gt;
## Top-right: &amp;quot;Browse Inventory&amp;quot;&lt;br /&gt;
## Make sure your number is capable of voice calling (it seems like most of them are)&lt;br /&gt;
## Follow the on-screen prompts to finish your purchase and activate the number. You will have to create a UseCase. Either &amp;quot;Mixed&amp;quot; or &amp;quot;Security Alert&amp;quot; should do. &lt;br /&gt;
# Ensure compliance with local regulations&lt;br /&gt;
## Go back to the number summary: &amp;quot;Developer&amp;quot; -&amp;gt; &amp;quot;Numbers&amp;quot; -&amp;gt; &amp;quot;Numbers &amp;amp; Senders&amp;quot;. You should now have you number listed. Click on it. &lt;br /&gt;
## At the top there is a menu, select &amp;quot;Voice&amp;quot;&lt;br /&gt;
## You should see some links to set up brand identification and compliance (what will you be using the number for, the company associated with the number, etc). Follow the on-screen instructions. Once compliance has been requested it may take a few days to be approved. &lt;br /&gt;
## While you wait, you also need to create a Voice Channel. In this same menu, click on &amp;quot;+ Create channel&amp;quot;. You can see your channels from the side bar navigation: &amp;quot;Developer&amp;quot; -&amp;gt; &amp;quot;Voice&amp;quot; -&amp;gt; &amp;quot;Voice Setup&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Information Needed to Make Calls ==&lt;br /&gt;
&lt;br /&gt;
You need a few pieces of info: &lt;br /&gt;
&lt;br /&gt;
* API Access Key&lt;br /&gt;
** In the side bar navigation: &amp;quot;Developer&amp;quot; -&amp;gt; &amp;quot;API Access Keys&amp;quot; (at the bottom)&lt;br /&gt;
** Make a new key. Keep it somewhere safe.&lt;br /&gt;
* Workspace ID&lt;br /&gt;
** In the side bar navigation: &amp;quot;Settings&amp;quot; (at the bottom) -&amp;gt; &amp;quot;Workspaces&amp;quot; -&amp;gt; Click on your workspace&lt;br /&gt;
* Channel ID&lt;br /&gt;
** In the side bar navigation: &amp;quot;Developer&amp;quot; -&amp;gt; &amp;quot;Voice&amp;quot; -&amp;gt; &amp;quot;Voice Setup&amp;quot; -&amp;gt; Click on your voice channel -&amp;gt; Settings (top right gear) &lt;br /&gt;
* Call ID&lt;br /&gt;
** Only available once the call is placed. See the script below. &lt;br /&gt;
* Outgoing number&lt;br /&gt;
** In the side bar navigation: &amp;quot;Developer&amp;quot; -&amp;gt; &amp;quot;Numbers&amp;quot; -&amp;gt; &amp;quot;Numbers &amp;amp; Senders&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Placing a Call == &lt;br /&gt;
&lt;br /&gt;
You can follow the documentation here: https://docs.bird.com/api/voice-api/voice-calls-api. Here is a python example script: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import json, requests, time&lt;br /&gt;
&lt;br /&gt;
# settings&lt;br /&gt;
workspaceId = &#039;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&#039;&lt;br /&gt;
channelId = &#039;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&#039;&lt;br /&gt;
APIKEY = &#039;YourAPIKey&#039;&lt;br /&gt;
outgoing = &#039;16042221047&#039; # outgoing number with country code&lt;br /&gt;
targetnumber = &#039;YourPurcahsedPhoneNumber&#039; # who to call&lt;br /&gt;
message = &amp;quot;Hello, world! This is my first message.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# place a call&lt;br /&gt;
# https://docs.bird.com/api/voice-api/voice-calls-api/initiate-an-outbound-call&lt;br /&gt;
def place_call(number):&lt;br /&gt;
&lt;br /&gt;
    # place the call&lt;br /&gt;
    response = requests.post(&lt;br /&gt;
        f&amp;quot;https://api.bird.com/workspaces/{workspaceId}/channels/{channelId}/calls&amp;quot;,&lt;br /&gt;
        headers={&amp;quot;Authorization&amp;quot;:f&amp;quot;AccessKey {APIKEY}&amp;quot;,&amp;quot;Content-Type&amp;quot;:&amp;quot;application/json&amp;quot;},&lt;br /&gt;
        data=json.dumps({&lt;br /&gt;
        &amp;quot;from&amp;quot;: outgoing,&lt;br /&gt;
        &amp;quot;to&amp;quot;: number,&lt;br /&gt;
        &amp;quot;ringTimeout&amp;quot;: 60,&lt;br /&gt;
        &amp;quot;maxDuration&amp;quot;: 120,&lt;br /&gt;
        &amp;quot;record&amp;quot;: False,&lt;br /&gt;
        })&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
    # call id is needed for the next steps&lt;br /&gt;
    data = response.json()&lt;br /&gt;
    callId = data[&#039;id&#039;]&lt;br /&gt;
    return callId&lt;br /&gt;
&lt;br /&gt;
# get the call status&lt;br /&gt;
# https://docs.bird.com/api/voice-api/voice-calls-api/get-a-call-insights&lt;br /&gt;
def get_call_status(callId):&lt;br /&gt;
    response = requests.get(&lt;br /&gt;
        f&amp;quot;https://api.bird.com/workspaces/{workspaceId}/channels/{channelId}/calls/{callId}/insights&amp;quot;,&lt;br /&gt;
        headers={&amp;quot;Authorization&amp;quot;:f&amp;quot;AccessKey {APIKEY}&amp;quot;,&amp;quot;Accept&amp;quot;:&amp;quot;*/*&amp;quot;},&lt;br /&gt;
    )&lt;br /&gt;
    data = response.json()&lt;br /&gt;
    return data[&#039;status&#039;]&lt;br /&gt;
&lt;br /&gt;
# text-to-voice: play message in the call &lt;br /&gt;
# https://docs.bird.com/api/voice-api/voice-calls-api/say-text-to-speech-tts&lt;br /&gt;
def play_message(callId, message):&lt;br /&gt;
    response = requests.post(&lt;br /&gt;
        f&amp;quot;https://api.bird.com/workspaces/{workspaceId}/channels/{channelId}/calls/{callId}/say&amp;quot;,&lt;br /&gt;
        headers={&amp;quot;Authorization&amp;quot;:f&amp;quot;AccessKey {APIKEY}&amp;quot;,&amp;quot;Content-Type&amp;quot;:&amp;quot;application/json&amp;quot;},&lt;br /&gt;
        data=json.dumps({&lt;br /&gt;
        &amp;quot;text&amp;quot;: message,&lt;br /&gt;
        &amp;quot;locale&amp;quot;: &amp;quot;en-US&amp;quot;,&lt;br /&gt;
        &amp;quot;voice&amp;quot;: &amp;quot;text&amp;quot;,&lt;br /&gt;
        &amp;quot;loop&amp;quot;: 10, # repeat the message this many times&lt;br /&gt;
        &amp;quot;timeout&amp;quot;: 30&lt;br /&gt;
        })&lt;br /&gt;
    )&lt;br /&gt;
    return response.json()&lt;br /&gt;
&lt;br /&gt;
# RUN =========================&lt;br /&gt;
&lt;br /&gt;
# place call&lt;br /&gt;
callId = place_call(targetnumber)&lt;br /&gt;
&lt;br /&gt;
# wait until call is answered, or until 30s has passed&lt;br /&gt;
t0 = time.time()&lt;br /&gt;
while time.time() - t0 &amp;lt; 30:&lt;br /&gt;
    status = get_call_status(callId)&lt;br /&gt;
    print(f&#039;Call status: &amp;quot;{status}&amp;quot;&#039;)&lt;br /&gt;
&lt;br /&gt;
    # call was answered&lt;br /&gt;
    if status == &#039;ongoing&#039;:&lt;br /&gt;
        break&lt;br /&gt;
&lt;br /&gt;
    # check again later&lt;br /&gt;
    time.sleep(1)&lt;br /&gt;
&lt;br /&gt;
# play the message&lt;br /&gt;
time.sleep(0.5)&lt;br /&gt;
play_message(callId, message+&#039;,&#039;) # comma after message introduces a pause between loops&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Alarms]]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
</feed>