<?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-10-19T14:09:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.6</generator>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Quickstart_Linux&amp;diff=3643</id>
		<title>Quickstart Linux</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Quickstart_Linux&amp;diff=3643"/>
		<updated>2026-09-29T16:17:26Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* ROODY Package Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This quickstart shows you how to install the MIDAS packages on a linux box and create a &#039;&#039;&#039;MIDAS experiment&#039;&#039;&#039;. &lt;br /&gt;
The linux box will be called the MIDAS &#039;&#039;&#039;&#039;&#039;experiment host&#039;&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
Log on to the &#039;&#039;[[#Introduction|Experiment Host]]&#039;&#039; and decide on a name for the MIDAS experiment (the &#039;&#039;experiment name&#039;&#039;).&lt;br /&gt;
In these instructions, the MIDAS packages and experiment will be installed under the username &amp;quot;johnfoo&amp;quot;. &lt;br /&gt;
The ODB and other shared memory buffers for the MIDAS experiment will reside on the &#039;&#039;experiment host&#039;&#039; (localhost).&lt;br /&gt;
MIDAS and the other required packages will be installed under directory  {{Filepath|path=$HOME/packages}}. The MIDAS &#039;&#039;experiment directory&#039;&#039; will be  {{Filepath|path=$HOME/online}} and the MIDAS &#039;&#039;experiment name&#039;&#039; will be &amp;quot;e777&amp;quot;. The name of the &#039;&#039;experiment host&#039;&#039; will be &amp;quot;mhostpc&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
;NOTE&lt;br /&gt;
: The user should substitute directory paths for the MIDAS packages and experiment directory as required, and names for &#039;&#039;experiment host&#039;&#039;, username, &#039;&#039;experiment name&#039;&#039; appropriate to his/her own setup.&lt;br /&gt;
&lt;br /&gt;
== Experimental setup ==&lt;br /&gt;
These instructions describe setting up an experiment that will run ONLY on the MIDAS &#039;&#039;experiment host&#039;&#039; computer (i.e. &#039;&#039;&#039;localhost only&#039;&#039;&#039;). In this case, the MIDAS &#039;&#039;experiment host&#039;&#039; has access to any hardware required, and all frontends, logger, analyzer etc. run on the one computer. &lt;br /&gt;
&lt;br /&gt;
Modifications to run an experiment with additional frontend(s) running &#039;&#039;&#039;remotely&#039;&#039;&#039; (i.e. on remote cpu(s)) will also be described.&lt;br /&gt;
Follow the instructions for setting up a localhost-only experiment until indicated. &lt;br /&gt;
 &lt;br /&gt;
In both cases, the main MIDAS applications (e.g. [[mlogger]], [[mhttpd]]) run on the MIDAS &#039;&#039;experiment host&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Environment Variables==&lt;br /&gt;
The following Environment variables should to be added to the  {{File|name=.cshrc}} or {{File|name=.bashrc}} file (depending on your shell) in the {{Filepath|path=$HOME}} directory on the &#039;&#039;experiment host&#039;&#039;,  so that they will be defined at login. &#039;&#039;&#039;Substitute appropriate values for your own setup&#039;&#039;&#039;. &lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! csh  !! bash !! comment&lt;br /&gt;
|-&lt;br /&gt;
| setenv MIDASSYS $HOME/packages/midas ||  export MIDASSYS=$HOME/packages/midas ||Base directory of the MIDAS package&lt;br /&gt;
|-&lt;br /&gt;
| setenv MIDAS_EXPTAB $HOME/online/exptab || export MIDAS_EXPTAB=$HOME/online/exptab  || MIDAS experiment table &lt;br /&gt;
|-&lt;br /&gt;
| setenv MIDAS_EXPT_NAME e777  || export MIDAS_EXPT_NAME=e777  || MIDAS experiment name&lt;br /&gt;
|-&lt;br /&gt;
| setenv PATH .:$MIDASSYS/bin:$PATH  || export PATH=$PATH:$MIDASSYS/bin || path&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Logout and login again, or source {{File|name=.cshrc}} (source {{File|name=.bashrc}}) for the changes to take effect.&lt;br /&gt;
;NOTE&lt;br /&gt;
: See [[MIDAS environment variables]] for a list of environment variables used by MIDAS.&lt;br /&gt;
&lt;br /&gt;
== ROOT Package Installation ==&lt;br /&gt;
MIDAS has optional integration with [https://root.cern.ch ROOT]. ROOT is not required for acquiring data or storing it in midas files, but is used by some of the analysis tools (including the example analyzer that will be built later in this Quickstart). It is also possible to write midas data directly to ROOT files if desired.&lt;br /&gt;
&lt;br /&gt;
If you require ROOT integration, follow the installation instructions on the [https://root.cern.ch ROOT website] and set the ROOTSYS environment variable.&lt;br /&gt;
&lt;br /&gt;
If you do not require ROOT integration, leave the ROOTSYS variable undefined.&lt;br /&gt;
&lt;br /&gt;
== Adding SSL support ==&lt;br /&gt;
&lt;br /&gt;
We recommend running mhttpd (the MIDAS web server) behind an industry-grade web proxy like apache httpd or nginx. httpd/nginx will then handle the SSL security. It is however also possible to build mhttpd with built-in SSL support. See [[Mhttpd|the mhttpd documentation]] for more details about web security.&lt;br /&gt;
&lt;br /&gt;
If you wish to enable SSL support in mhttpd itself:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
  [mhostpc] cd $MIDASSYS&lt;br /&gt;
  [mhostpc] make mbedtls&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MIDAS Package Installation ==&lt;br /&gt;
The MIDAS package will be installed on the &#039;&#039;experiment host&#039;&#039; in the directory given by MIDASSYS - see [[#Environment Variables]].&lt;br /&gt;
&lt;br /&gt;
Install the MIDAS and other package(s) from the MIDAS git repository in an xterm as follows:&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] mkdir $HOME/packages&lt;br /&gt;
   [mhostpc] cd $HOME/packages&lt;br /&gt;
   [mhostpc] git clone https://gitlab.triumf.ca/midas/midas.git --recurse-submodules&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already cloned MIDAS and forgot the &amp;quot;--recurse-submodules&amp;quot;, you can do a &amp;quot;git submodule update --init --recursive&amp;quot; later. If you want to pull MIDAS later to update to the current version, you need either &amp;quot;git pull --recurse-submodules&amp;quot;. To tell git to always recurse, you can set a global flag via &amp;quot;git config submodule.recurse true&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The MIDAS Makefile will auto-detect whether MSCB, ROOT, MYSQL, SQLITE, ODBC etc. are available (or have been installed). If you need these features, make sure they are available before building the MIDAS package.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] cd $MIDASSYS&lt;br /&gt;
   [mhostpc] mkdir build&lt;br /&gt;
   [mhostpc] cd build&lt;br /&gt;
   [mhostpc] cmake ..                  ### configure build process (see note below about cmake/cmake3)&lt;br /&gt;
   [mhostpc] make install              ### build and install midas to bin/ and lib/ directories&lt;br /&gt;
   [mhostpc] cd ..&lt;br /&gt;
   [mhostpc] ls -l bin/odbedit         ### check that odbedit has been created (do not run it yet)&lt;br /&gt;
&amp;lt;/small&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
MIDAS requires cmake version 3.10 or later. On some systems, you have to call &amp;quot;cmake3 ..&amp;quot;, on others just &amp;quot;cmake ..&amp;quot;. Some systems might require you to install cmake first (see the [https://cmake.org/download/ cmake website; installation is very simple).&lt;br /&gt;
&lt;br /&gt;
In case of problems see &lt;br /&gt;
* [[Installation#Installing MIDAS|gitlab is down]] or &lt;br /&gt;
* [[Installation/Compilation problems#SSL certificate errors|SSL certificate errors]].&lt;br /&gt;
&lt;br /&gt;
==ROOTANA Package Installation==&lt;br /&gt;
&lt;br /&gt;
rootana is an optional framework for analyzing midas data in realtime and displaying plots (either by a graphical interface or via webpages). Most of the features are now available in manalyzer, which is included in the base midas install.&lt;br /&gt;
&lt;br /&gt;
If you require the legacy ROOTANA package, you can install it with:&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
    [mhostpc] cd $HOME/packages&lt;br /&gt;
    [mhostpc] git clone https://gitlab.triumf.ca/midas/rootana.git&lt;br /&gt;
    [mhostpc] cd rootana&lt;br /&gt;
    [mhostpc] make&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
add ROOTANASYS=$HOME/packages/rootana to the login file.&lt;br /&gt;
&lt;br /&gt;
Install the JSROOT package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd $HOME/packages&lt;br /&gt;
git clone https://github.com/linev/jsroot.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
add JSROOTSYS=$HOME/packages/jsroot to the login file.&lt;br /&gt;
&lt;br /&gt;
==ROODY Package Installation==&lt;br /&gt;
&lt;br /&gt;
ROODY is a legacy package for displaying live ROOT histograms. It is generally not used by new experiments.&lt;br /&gt;
&lt;br /&gt;
If ROODY is needed,&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
    [mhostpc] cd $HOME/packages&lt;br /&gt;
    [mhostpc] git clone https://gitlab.triumf.ca/midas/roody.git&lt;br /&gt;
    [mhostpc] cd roody&lt;br /&gt;
    [mhostpc] make&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create the Experiment file exptab ==&lt;br /&gt;
In this example, the experimental directory is {{Filepath|path=$HOME/online}}. Create this directory on the &#039;&#039;experiment host&#039;&#039; (localhost):&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] mkdir $HOME/online&lt;br /&gt;
   [mhostpc] cd $HOME/online&amp;lt;/small&amp;gt;&lt;br /&gt;
Then create the [[exptab]] file {{Filepath|path=$HOME/online/exptab}} containing the three parameters:&lt;br /&gt;
# the experiment name &lt;br /&gt;
# location of MIDAS shared memory buffers&lt;br /&gt;
# username&lt;br /&gt;
as follows (using parameters for your own experiment):&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] cat &amp;gt; exptab&lt;br /&gt;
    e777 /home/johnfoo/online johnfoo&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The path of the  {{File|name=exptab}} file is given by MIDAS_EXPTAB - see [[#Environment Variables]].&lt;br /&gt;
&lt;br /&gt;
== Create shared memory files  ==&lt;br /&gt;
At this point you should be able to run [[odbedit]] on the &#039;&#039;experiment host&#039;&#039; (localhost). The first time  {{Utility|name=odbedit}} is run, it will create the required  {{File|name=.*.SHM}} files  in the MIDAS experiment directory  {{Filepath|path=$HOME/online}}. These are the saved files for the MIDAS shared memory.&lt;br /&gt;
&lt;br /&gt;
The default directory  {{Filepath|path=$HOME/online}} will contain the MIDAS messages file ({{File|name=midas.log}}) and&lt;br /&gt;
any data files you may create. If you want an alternative location for the data files see [[#Customizing your experiment]].&lt;br /&gt;
  &lt;br /&gt;
Run {{Utility|name=odbedit}}, and type {{Odbedit cmd|cmd=ls}} to list the default directories. &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] odbedit&lt;br /&gt;
 [local:e777:S]/&amp;gt;ls&lt;br /&gt;
 Experiment&lt;br /&gt;
 System&lt;br /&gt;
 Programs&lt;br /&gt;
 Logger&lt;br /&gt;
 Runinfo&lt;br /&gt;
 Alarms&amp;lt;/small&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
== Run the MIDAS Web Server ==&lt;br /&gt;
&lt;br /&gt;
=== Using apache ===&lt;br /&gt;
&lt;br /&gt;
Recommended for production systems with maximum security is to run mhttpd behind an industry-standard SSL/https proxy with password protection. We document instructions for apache here, but you could nginx instead.&lt;br /&gt;
&lt;br /&gt;
To do this using apache httpd on CentOS-7, do this:&lt;br /&gt;
* configure apache httpd per instructions for [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog Ubuntu] or [https://daq00.triumf.ca/DaqWiki/index.php/SLinstall#Configure_HTTPS_server_.28CentOS7.29 CentOS 7]&lt;br /&gt;
* run mhttpd&lt;br /&gt;
* use web browser to connect to https://mhostpc/&lt;br /&gt;
* enter the user name and password configured in apache httpd&lt;br /&gt;
* the midas status page should open&lt;br /&gt;
&lt;br /&gt;
=== Standalone (less secure) ===&lt;br /&gt;
&lt;br /&gt;
For simplified installation, one can use standalone mhttpd with built-in https and password protection. This configuration&lt;br /&gt;
is only as secure as the underlying mongoose and OpenSSL web server and encryption packages. Use the odbedit tool to edit settings in the [[Webserver_ODB_tree|Webserver ODB tree]]:&lt;br /&gt;
&lt;br /&gt;
* Set &amp;quot;Enable https port&amp;quot; to &amp;quot;y&amp;quot;&lt;br /&gt;
* Set &amp;quot;https port passwords&amp;quot; to &amp;quot;y&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Many current operating systems implement a built-in firewall which will block outside access to mhttpd. See instructions for [https://daq00.triumf.ca/DaqWiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29 CentOS 7].&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;
&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:13880: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:13881:mongoose,ERROR] please create password file: touch /home/johnfoo/online/htpasswd.txt&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:13818:mongoose,ERROR] mongoose web server password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot; has no passwords for realm &amp;quot;exptname&amp;quot;&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:13819:mongoose,ERROR] please add passwords by running: htdigest /home/johnfoo/online/htpasswd.txt exptname midas&lt;br /&gt;
  mongoose_init: Error: Cannot initialize authorization object!&lt;br /&gt;
  Error: Could not start the mongoose web server, see messages and midas.log, bye!&lt;br /&gt;
&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. (htdigest is part of the httpd-tools package)&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;
&lt;br /&gt;
Run {{Utility|name=mhttpd}} again.&lt;br /&gt;
&lt;br /&gt;
If you get error messages like &amp;lt;small&amp;gt;&amp;lt;code&amp;gt;https port &amp;quot;[::]:8443&amp;quot; requested, but mhttpd compiled without MG_ENABLE_SSL&amp;lt;/code&amp;gt;&amp;lt;/small&amp;gt; then you need to re-compile MIDAS after [[Mhttpd#Build_mhttpd_with_SSL_support|adding SSL support]].&lt;br /&gt;
&lt;br /&gt;
Otherwise, you will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;&lt;br /&gt;
  HTTP Digest authentication with realm &amp;quot;exptname&amp;quot; and password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot;&lt;br /&gt;
  Hostlist off, connections from anywhere will be accepted&lt;br /&gt;
  Listening on &amp;quot;http://localhost:8080&amp;quot;, passwords OFF, hostlist OFF&lt;br /&gt;
  Listening on &amp;quot;http://[::1]:8080&amp;quot;, passwords OFF, hostlist OFF&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:15739:mongoose_listen,ERROR] cannot find SSL certificate file &amp;quot;/home/johnfoo/online/ssl_cert.pem&amp;quot;&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:15740:mongoose_listen,ERROR] please create SSL certificate file using openssl: cd $MIDASSYS; openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key -subj &amp;quot;/C=/ST=/L=/O=midas/OU=mhttpd/CN=localhost&amp;quot;; 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;
  [mhttpd,ERROR] [mhttpd.cxx:15741:mongoose_listen,ERROR] or using certbot (recommened): setup certbot per Let&#039;s Encrypt instructions, certificates are typically saved in /etc/letsencrypt/live/$HOSTNAME/, copy fullchain.pem and privkey.pem to $MIDASSYS; cd $MIDASSYS; cat fullchain.pem privkey.pem &amp;gt; ssl_cert.pem&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:15918:mongoose_init,ERROR] Failed to listen on a TCP port enabled in ODB /WebServer&lt;br /&gt;
  Error: Could not start the mongoose web server, see messages and midas.log, bye!&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a self-signed certificate suitable for initial testing by executing the commands printed by mhttpd.&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/https proxy (apache httpd).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now restart  {{Utility|name=mhttpd}}&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&lt;br /&gt;
 HTTP Digest authentication with realm &amp;quot;test_pol&amp;quot; and password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot;&lt;br /&gt;
 Hostlist off, connections from anywhere will be accepted&lt;br /&gt;
 Listening on &amp;quot;http://localhost:8080&amp;quot;, passwords OFF, hostlist OFF&lt;br /&gt;
 Listening on &amp;quot;http://[::1]:8080&amp;quot;, passwords OFF, hostlist OFF&lt;br /&gt;
 Mongoose web server will use https certificate file &amp;quot;./ssl_cert.pem&amp;quot;&lt;br /&gt;
 Listening on &amp;quot;https://[::]:8443&amp;quot;, passwords enabled, hostlist OFF&lt;br /&gt;
 Mongoose web server is using 1 threads&lt;br /&gt;
 Mongoose web server is using 2 threads&lt;br /&gt;
 Mongoose web server is using 3 threads&lt;br /&gt;
 Mongoose web server is using 4 threads&amp;lt;/small&amp;gt;&lt;br /&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;
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]]. To use some other ports, change the relevant values in the [[Webserver_ODB_tree|Webserver ODB tree]].&lt;br /&gt;
&lt;br /&gt;
== Run the MIDAS logger ==&lt;br /&gt;
Start the MIDAS logger [[mlogger]] on the &#039;&#039;experiment host&#039;&#039; (localhost) :&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mlogger&amp;lt;/small&amp;gt; &lt;br /&gt;
This should start without error. It is usually run as a daemon, however in this case it is run in a terminal to check for errors. Starting the midas logger [[mlogger]] will automatically create more keys in the  {{Odbpath|path=/Logger}} ODB tree.&lt;br /&gt;
&lt;br /&gt;
From the MIDAS status page, go to the &amp;quot;Programs&amp;quot; page, then the &amp;quot;Logger&amp;quot; page and set ODB variables:&lt;br /&gt;
* Required -&amp;gt; set to &amp;quot;y&amp;quot;&lt;br /&gt;
* Start command -&amp;gt; set to &amp;quot;mlogger -D&amp;quot;&lt;br /&gt;
* Alarm Class -&amp;gt; set to &amp;quot;Alarm&amp;quot;&lt;br /&gt;
&lt;br /&gt;
To test this, go to the &amp;quot;Programs&amp;quot; page, press &amp;quot;stop logger&amp;quot;, then &amp;quot;start logger&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Start a run, wait 10 seconds, stop the run.&lt;br /&gt;
&lt;br /&gt;
From the MIDAS &amp;quot;Status&amp;quot; page, go to the &amp;quot;logging channels -&amp;gt; channel #0&amp;quot; and set ODB variables:&lt;br /&gt;
* Output -&amp;gt; &amp;quot;FILE&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Start a run, go to the &amp;quot;Status&amp;quot; page, observe that the output file is written with lz4 compression and has the &amp;quot;mid.lz4&amp;quot; extension.&lt;br /&gt;
&lt;br /&gt;
Stop the run.&lt;br /&gt;
&lt;br /&gt;
== Run test frontend ==&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;fetest&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the MIDAS &amp;quot;Status&amp;quot; page there will be 5 new equipment entries:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Equipment created by the fetest program&lt;br /&gt;
|-&lt;br /&gt;
! Equipment name !! Data it sends !! How often data is sent&lt;br /&gt;
|-&lt;br /&gt;
| test_random || Random data banks || 1Hz&lt;br /&gt;
|-&lt;br /&gt;
| test_slow || Example slow control data for testing the midas history plots || 1Hz, even when a run isn&#039;t in progress&lt;br /&gt;
|-&lt;br /&gt;
| test_rare || Data that look like a sine wave || 0.1Hz, even when a run isn&#039;t in progress&lt;br /&gt;
|-&lt;br /&gt;
| test_bulk || Large events || 1Hz&lt;br /&gt;
|-&lt;br /&gt;
| test_rpc || None. It shows an example of a &amp;quot;remote procedure call&amp;quot; (RPC) handler. Javascript/C++/Python code can connect to the program, and it will respond with the current time (in this toy example) || never&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note the event counters for test_slow and test_rare are already incrementing.&lt;br /&gt;
&lt;br /&gt;
Start a run.&lt;br /&gt;
&lt;br /&gt;
Observe that the event counters for test_bulk and test_random are also incrementing now, and that the output data file size is growing.&lt;br /&gt;
&lt;br /&gt;
Click on the &amp;quot;Event dump&amp;quot; page and then the &amp;quot;Run&amp;quot; button. You&#039;ll see the raw data that is being written to disk. (The data from most of the equipment is double-precision floating point numbers; the data from the &amp;quot;bulk&amp;quot; equipment is just a bunch of zeros).&lt;br /&gt;
&lt;br /&gt;
Return the status page and stop the run.&lt;br /&gt;
&lt;br /&gt;
== Create a history plot ==&lt;br /&gt;
&lt;br /&gt;
Go to the MIDAS &amp;quot;History&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Say &amp;quot;new&amp;quot;, panel name &amp;quot;test&amp;quot;. In the history editor select event &amp;quot;test_slow&amp;quot;, and click the &amp;quot;save&amp;quot; button (you can ignore the rest of the options for now). If the &amp;quot;test_slow&amp;quot; event isn&#039;t listed, make sure that the mlogger program is running, as described above.&lt;br /&gt;
&lt;br /&gt;
History plot &amp;quot;test&amp;quot; should open with a sine-wave plot. Data on the plot should update as long as &amp;quot;fetest&amp;quot; is running (there is no need to start a run).&lt;br /&gt;
&lt;br /&gt;
== Clients run on Localhost only ==&lt;br /&gt;
;NOTE: &lt;br /&gt;
* If creating a MIDAS experiment with a &#039;&#039;&#039;REMOTE&#039;&#039;&#039; frontend, &#039;&#039;&#039;continue by following the instructions&#039;&#039;&#039; [[#Running with one or more REMOTE frontends]].&lt;br /&gt;
* If all clients are running on the Experiment Host (i.e. &#039;&#039;&#039;localhost&#039;&#039;&#039;), continue with the following instructions:&lt;br /&gt;
&lt;br /&gt;
=== Frontend and Analyzer (localhost) ===&lt;br /&gt;
&lt;br /&gt;
THIS SECTION IS VERY OBSOLETE&lt;br /&gt;
&lt;br /&gt;
There are several examples of [[Frontend user code]] ({{File|name=frontend.c}}) in the MIDAS package available under {{Filepath|path=$MIDASSYS/examples/}}. Choose a suitable example from this directory that you can later modify for your own particular setup (e.g. for a slow control, choose the {{Filepath|path=../slowcont/}} example). &lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;frontend&#039;&#039;&#039; is a program that usually reads data from the hardware and sends it to a buffer to be logged and analyzed. You can find documentation about the frontend structure under [[Frontend Application]], [[Frontend Operation]] and [[Frontend user code]].&lt;br /&gt;
&lt;br /&gt;
The example chosen here is from  {{Filepath|path=$MIDASSYS/examples/experiment/}}. It does &#039;&#039;&#039;not need any hardware&#039;&#039;&#039; and produces simulated events.  &lt;br /&gt;
&lt;br /&gt;
On the MIDAS &#039;&#039;experiment host&#039;&#039; (localhost), copy the example to the experiment directory and build it.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
      [mhostpc] cd $HOME/online&lt;br /&gt;
      [mhostpc] cp $MIDASSYS/examples/experiment/* .&lt;br /&gt;
      [mhostpc] make&amp;lt;/small&amp;gt;&lt;br /&gt;
The analyzer will only build if ROOT has previously been installed.&lt;br /&gt;
At this point the frontend and the analyzer should be ready if no errors were generated during the build. Try the frontend and analyzer by starting them in xterms. &lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
      [mhostpc] frontend&lt;br /&gt;
      [mhostpc] analyzer&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Equipment ODB tree ===&lt;br /&gt;
Starting the frontend will automatically create the  {{Odbpath|path=/Equipment}} ODB tree and one or more equipments. In this case, the equipments &amp;quot;trigger&amp;quot; and &amp;quot;scaler&amp;quot; have been defined by code in  {{File|name=frontend.c}} and created the first time frontend runs.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
     [mhostpc] odbedit&lt;br /&gt;
     [local:e777:S]/&amp;gt;ls /equipment&lt;br /&gt;
     Trigger                         &lt;br /&gt;
     Scaler  &amp;lt;/small&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
View the MIDAS main status web page (by pointing your browser to https://localhost:8443/ or appropriate port if not using the default).&lt;br /&gt;
Observe on the [[Status Page]] that the two Equipments (Trigger, Scaler) have appeared in the Equipment section (Figure 1) and are coloured green.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Click thumbnail to enlarge&#039;&#039;&#039;&lt;br /&gt;
[[File:quickstart_status_page.png|thumb|left|Figure 1: web server status page showing example frontend equipments]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;clear: both&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;  &amp;lt;!-- clear wraparound after thumbnail --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rather than using odbedit,  you can view the contents of these equipments by clicking on the ODB button, then on {{Odbpath|path=/Equipment}}, then {{Odbpath|path=Trigger}} or {{Odbpath|path=Scaler}}. See [[ODB Page]] for more information.&lt;br /&gt;
&lt;br /&gt;
=== Start a run ===&lt;br /&gt;
Start a run by pressing the Start button on the [[Status Page]].&lt;br /&gt;
The Equipment display on the Status Page will now show some event statistics (Figure 2)&lt;br /&gt;
&#039;&#039;&#039;Click thumbnail to enlarge&#039;&#039;&#039;&lt;br /&gt;
[[File:sample_frontend_status.png|thumb|left|Figure 2: Equipments shown on Status Page showing event statistics]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;clear: both&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;  &amp;lt;!-- clear wraparound after thumbnail --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The frontend will show an event display that will update when a run is started, e.g.&lt;br /&gt;
&lt;br /&gt;
 Sample Frontend connected to &amp;lt;local&amp;gt;. Press &amp;quot;!&amp;quot; to exit      18:48:2546:08&lt;br /&gt;
 ==========================================================================&lt;br /&gt;
 Run status:   Running    Run number 2                                   |/   /&lt;br /&gt;
 ===========================================================================&lt;br /&gt;
 Equipment     Status     Events     Events/sec Rate[B/s]  ODB-&amp;gt;FE FE-&amp;gt;OD&lt;br /&gt;
 ---------------------------------------------------------------------------&lt;br /&gt;
 Trigger       OK         13948      99.0       5413.0     0          140         &lt;br /&gt;
 Scaler        OK         15         0.3         15.4      0          15    &lt;br /&gt;
&lt;br /&gt;
The [[Status Page]] will also show events being generated (click the refresh button if necessary). &lt;br /&gt;
&lt;br /&gt;
=== Event Dump ===&lt;br /&gt;
While a run is in progress, the midas application [[mdump]] will provide you an event dump of the collected data from the running frontend, e.g.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
  mhostpc&amp;gt; mdump -l 50&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:whitesmoke&amp;quot;&amp;gt;blank&amp;lt;/span&amp;gt;&lt;br /&gt;
 - MIDAS revision: Mon Nov 2 11:50:51 2015 -0800 - 3b66779 -- Enter &amp;lt;!&amp;gt; to Exit ------- Midas Dump ---&lt;br /&gt;
 ------------------------ Event# 1 ------------------------&lt;br /&gt;
 Evid:0001- Mask:0000- Serial:0- Time:0x567a0c5d- Dsize:40/0x28&lt;br /&gt;
 #banks:2 - Bank list:-ADC0TDC0-&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:whitesmoke&amp;quot;&amp;gt;blank&amp;lt;/span&amp;gt;&lt;br /&gt;
 Bank:ADC0 Length: 8(I*1)/2(I*4)/4(Type) Type:Unsigned Integer*2&lt;br /&gt;
   1-&amp;gt; 0x0167 0x03c6 0x0069 0x0073 &lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:whitesmoke&amp;quot;&amp;gt;blank&amp;lt;/span&amp;gt;&lt;br /&gt;
 Bank:TDC0 Length: 8(I*1)/2(I*4)/4(Type) Type:Unsigned Integer*2&lt;br /&gt;
   1-&amp;gt; 0x0051 0x00ff 0x004a 0x00ec &lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
For further data processing/analysis, either the midas analyzer or the rootana can used for data display as well. &lt;br /&gt;
&lt;br /&gt;
=== Create a startup script (localhost) ===&lt;br /&gt;
It is useful to create a script that will automatically start all the required clients for the experiment. This is called a startup script. Here, the startup script will be  {{File|name=start_daq.sh}} (any name can be used). Create  {{Filepath|path=$HOME/online/bin/start_daq.sh}} on the &#039;&#039;experiment host&#039;&#039; as follows (supply the [[mhttpd]] ports if default is not used):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;small&amp;gt;#!/bin/sh&lt;br /&gt;
 # start_daq.sh&lt;br /&gt;
 cd $HOME/online&lt;br /&gt;
 odbedit -c clean&lt;br /&gt;
 #   start mhttpd on default port. (Mongoose https version)&lt;br /&gt;
 mhttpd  -D  # you can optionally restrict access to localhost and other specified hosts - see [[mhttpd]]&lt;br /&gt;
 xterm -e ./frontend &amp;amp;&lt;br /&gt;
 xterm -e ./analyzer &amp;amp;&lt;br /&gt;
 mlogger -D&lt;br /&gt;
 #end file&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before running this script, you will need to shutdown any running clients:&lt;br /&gt;
 &amp;lt;small&amp;gt;mhostpc&amp;gt; odbedit -c &amp;quot;sh all&amp;quot;&amp;lt;/small&amp;gt;&lt;br /&gt;
or you can use the  {{Utility|name=mhttpd}} [[Programs Page]] to shut them down.&lt;br /&gt;
&lt;br /&gt;
The script will start them as daemons. &lt;br /&gt;
By running the startup script start_daq.sh, several MIDAS applications will be started in sequence:&lt;br /&gt;
# Cleanup previous MIDAS application (if any).&lt;br /&gt;
# Start the MIDAS web server [mhttpd]&lt;br /&gt;
# Start the frontend application in its own xterm (for debugging purpose).&lt;br /&gt;
# Start the analyzer application in its own xterm (for debugging purpose).&lt;br /&gt;
# Start the MIDAS Data logger [mlogger]&lt;br /&gt;
  &amp;lt;small&amp;gt;[mhostpc] sh ./start_daq&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may wish to modify the script to restart missing clients only. &lt;br /&gt;
&lt;br /&gt;
Next [[#Customizing your experiment|customize your experiment]].&lt;br /&gt;
&lt;br /&gt;
== Running with one or more REMOTE frontends ==&lt;br /&gt;
These instructions assume you have already followed the instructions to setup an experiment running on the MIDAS experiment host (localhost), i.e. you have setup the MIDAS Environment variables, downloaded MIDAS packages, setup the [[mhttpd]] password and have {{Utility|name=mhttpd}} running successfully.&lt;br /&gt;
&lt;br /&gt;
In the case of &#039;&#039;&#039;remote&#039;&#039;&#039; frontend(s), the remote cpu(s) typically have access to some or all of the hardware. They might be VMIC cpus running in VME crates for example, connected to the MIDAS Host via Ethernet.  They read data from the hardware and send it back to the MIDAS &#039;&#039;experiment host&#039;&#039; to be logged and analyzed.&lt;br /&gt;
&lt;br /&gt;
=== Experimental setup (Remote) ===&lt;br /&gt;
These instructions assume that the MIDAS &#039;&#039;experiment host&#039;&#039; computer is 64-bit (if not see [[#Build 32-bit MIDAS libraries|note below]]), and there is one &#039;&#039;remote host&#039;&#039;, a 32-bit machine named &amp;quot;rlxhost&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;remote host&#039;&#039; mounts the {{Filepath|path=/home}} disk of the &#039;&#039;experiment host&#039;&#039;, so that it &#039;&#039;&#039;has access to the MIDAS packages&#039;&#039;&#039;, the {{Filepath|path=$HOME/online}} directory and shares the .cshrc (or .bashrc) script. It is convenient to set up ssh keys (use ssh-keygen) so that the &#039;&#039;remote host&#039;&#039; can be accessed without supplying the password from the &#039;&#039;experiment host&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If your setup is different, you will have to make changes as appropriate.  &lt;br /&gt;
&lt;br /&gt;
=== Build 32-bit MIDAS libraries ===&lt;br /&gt;
NOTE&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:40px;margin-right:40px;&amp;quot;&amp;gt;&lt;br /&gt;
If the MIDAS &#039;&#039;experiment host&#039;&#039; computer is 32-bit (i.e. the same as the &#039;&#039;remote host&#039;&#039;), which is a simpler setup, you will have built the 32-bit MIDAS libraries already, and can skip the rest of this section. Note however, that in the .cshrc file in the  [[#Modify .cshrc (.bashrc) for Remote host|following section]] you will not need the lines starting &amp;quot;# select 64-bit or 32-bit MIDAS and ROOT&amp;quot;.  The PATH should contain &amp;lt;span style=&amp;quot;color:#214200; font-weight:normal; font-style:italic&amp;quot;&amp;gt;$MIDASSYS/bin&amp;lt;/span&amp;gt; on both experiment host and remote host. This will point to the 32-bit MIDAS libraries. &lt;br /&gt;
------------------------------&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Assuming the MIDAS host computer is 64-bit, you will have already built the 64-bit MIDAS libraries.&lt;br /&gt;
In this case, if the remote frontend is 32-bit, you will need to build the 32-bit MIDAS libraries on the 64-bit machine, i.e.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
    [mhostpc] cd /home/packages/midas&lt;br /&gt;
    [mhostpc] make linux32                ### build the 32-bit MIDAS libraries on 64-bit machine&lt;br /&gt;
    [mhostpc] ls -l linux-m32/bin/odbedit ### check that the 32-bit odbedit has been created &amp;lt;/small&amp;gt;&lt;br /&gt;
Do not run  {{Utility|name=odbedit}} yet on the &#039;&#039;remote host&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If the &amp;quot;make linux32&amp;quot; command fails, you may need to install 32bit support for your compiler (e.g. &amp;quot;apt install g++-multilib&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
=== Modify .cshrc (.bashrc) for Remote host ===&lt;br /&gt;
Add the following to the {{File|name=.cshrc}} (modified appropriately if using {{File|name=.bashrc}}).  When running with a REMOTE Host, the application [[mserver]] will be started (using a particular port) on the MIDAS &#039;&#039;experiment host&#039;&#039; machine only.  Note that the environment variable MIDAS_SERVER_HOST is defined on the remote machine(s) but NOT on the &#039;&#039;experiment host&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
If ROOT has been installed properly and the script &amp;lt;ROOT installation directory&amp;gt;/bin/thisroot.sh is called from .cshrc or .bashrc, the ROOTSYS environment variable should be defined and the ROOT bin directory should be in the PATH environment variable. Make sure that this is the case.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 # setenv MIDAS_HOST mhostpc   # substitute your experiment host name&lt;br /&gt;
 # setenv REMOTE_HOST rlxhost  # substitute your remote host name&lt;br /&gt;
 # setup the MIDAS mserver host&lt;br /&gt;
 #&lt;br /&gt;
 switch (`hostname`)&lt;br /&gt;
 case $MIDAS_HOST*:                &lt;br /&gt;
   unsetenv MIDAS_SERVER_HOST     ## MIDAS_SERVER_HOST not defined&lt;br /&gt;
   breaksw&lt;br /&gt;
 default:&lt;br /&gt;
 setenv MIDAS_SERVER_HOST $MIDAS_HOST.triumf.ca:1175  ## for remote host, define MIDAS_SERVER_HOST, use your domain here&lt;br /&gt;
                                                      ## as hostname + domain name + default mserver port&lt;br /&gt;
                                                      ## port must match that of [[mserver]] used in start_daq.sh &lt;br /&gt;
 endsw&lt;br /&gt;
 #&lt;br /&gt;
 # select 64-bit or 32-bit MIDAS&lt;br /&gt;
 #&lt;br /&gt;
 switch (`uname -i`)&lt;br /&gt;
 case i386:&lt;br /&gt;
   setenv PATH .:$MIDASSYS/linux-m32/bin:$PATH&lt;br /&gt;
   breaksw&lt;br /&gt;
 default:&lt;br /&gt;
   setenv PATH .:$MIDASSYS/linux/bin:$PATH&lt;br /&gt;
 endsw&lt;br /&gt;
 #&lt;br /&gt;
 setenv PATH .:$HOME/online/bin:$HOME/packages/roody/bin:$PATH&lt;br /&gt;
 #&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
After executing {{File|name=.cshrc}} (or {{File|name=.bashrc}}) or logging out, on the MIDAS host (mhostpc) make sure environment variable MIDAS_SERVER_HOST is NOT defined&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] echo $MIDAS_SERVER_HOST&lt;br /&gt;
 [mhostpc] MIDAS_SERVER_HOST: Undefined variable.&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and on the  &#039;&#039;&#039;&#039;&#039;remote host&#039;&#039;&#039;&#039;&#039;, make sure MIDAS_SERVER_HOST IS defined: &lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] echo $MIDAS_SERVER_HOST&lt;br /&gt;
  [rlxhost] MIDAS_SERVER_HOST&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also on the &#039;&#039;remote host&#039;&#039;, make sure that the correct (32-bit)  {{Utility|name=odbedit}} will be used (do not run it yet!)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] which odbedit&lt;br /&gt;
 /home/johnfoo/packages/midas/linux-m32/bin/odbedit&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Grant Remote host access permission === &lt;br /&gt;
Give permission for the remote host(s) to access the experiment by following the instructions to [[Security#MIDAS programs on remote machines|allow MIDAS programs on remote machines]].  If the MIDAS web server [[mhttpd]] is running, use [[ODB Page]] to edit the ODB keys listed, otherwise use [[odbedit]] on the &#039;&#039;experiment host&#039;&#039; machine.&lt;br /&gt;
 &lt;br /&gt;
=== Start mserver on Experiment Host ===&lt;br /&gt;
The application [[mserver]] is not required when running an experiment on the &#039;&#039;experiment host&#039;&#039; (localhost) only, but it &#039;&#039;&#039;IS required&#039;&#039;&#039; for access from a &#039;&#039;&#039;REMOTE&#039;&#039;&#039; frontend.&lt;br /&gt;
Start [[mserver]] on MIDAS host (default port 1175) or use the &amp;quot;-p&amp;quot; option for a different port.&lt;br /&gt;
The port must match the port defined for environment variable MIDAS_SERVER_HOST in {{File|name=.cshrc}} (or {{File|name=.bashrc}}) [[#Modify .cshrc (.bashrc) for Remote host|above]].&lt;br /&gt;
  &amp;lt;small&amp;gt;[mhostpc] mserver -D&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The environment variables on the REMOTE host should be:&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;&lt;br /&gt;
    [rlxhost] printenv | grep MIDAS&lt;br /&gt;
    MIDASSYS=/home/e777/packages/midas&lt;br /&gt;
    MIDAS_EXPT_NAME=e777&lt;br /&gt;
    MIDAS_SERVER_HOST=mhostpc.triumf.ca:1175&amp;lt;/span&amp;gt;&lt;br /&gt;
(a different port may be used - see above)&lt;br /&gt;
&lt;br /&gt;
=== Check access to ODB from Remote host ===&lt;br /&gt;
Run {{Utility|name=odbedit}} on the remote host to check access to ODB. &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] odbedit&lt;br /&gt;
 [mhostpc.triumf.ca:1175:e777:Stopped]/&amp;gt;ls &amp;lt;/span&amp;gt;&lt;br /&gt;
If it does not work correctly, check that &lt;br /&gt;
* MIDAS_SERVER_HOST is defined on REMOTE host with same port as [[mserver]]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:darkcyan;font-style:italic&amp;quot;&amp;gt;mserver&amp;lt;/span&amp;gt; is running on MIDAS host with the correct port&lt;br /&gt;
* MIDAS_SERVER_HOST is NOT defined on MIDAS host&lt;br /&gt;
* remote access permission to REMOTE host has been granted as described above.&lt;br /&gt;
&lt;br /&gt;
=== Build the analyzer on Experiment Host ===&lt;br /&gt;
The analyzer will be built and run on the MIDAS &#039;&#039;experiment host&#039;&#039; machine.&lt;br /&gt;
Select an example from $MIDASSYS/examples/ (see [[#Frontend and Analyzer (localhost)]]) and copy it to $HOME/online on the MIDAS host machine. Since we are assuming a 64-bit MIDAS host and a 32-bit remote host, edit the example Makefile so only the analyzer will be built. &lt;br /&gt;
&lt;br /&gt;
=== Build the frontend (32bit) for Remote host ===&lt;br /&gt;
The frontend runs on a 32-bit remote host in this example. It therefore must either&lt;br /&gt;
* be built 32-bit on the 64-bit MIDAS host with the &amp;quot;-m32&amp;quot; flag &lt;br /&gt;
* or built on the REMOTE host&lt;br /&gt;
and in either case the [[#Build 32-bit MIDAS libraries|32-bit MIDAS libraries]] used for linking. &lt;br /&gt;
&lt;br /&gt;
To avoid confusion, create a different subdirectory for the frontend, e.g.&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] mkdir $HOME/online/fe_32&amp;lt;/span&amp;gt;&lt;br /&gt;
Copy the Makefile and frontend code from the same example to this directory.&lt;br /&gt;
Modify the Makefile as needed, and only build the frontend.  &lt;br /&gt;
&lt;br /&gt;
Once built, start the frontend in an xterm on the REMOTE host. &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] $HOME/online/fe_32/frontend&amp;lt;/span&amp;gt;&lt;br /&gt;
Check that it connects successfully to the experiment and the Equipments appear on the [[Status Page]] as described under [[#Frontend and Analyzer (localhost)]].  The Equipment Status (Figure 2) should show that the Equipments are now running on the remote cpu, i.e. &amp;quot;SampleFrontend@rlxhost.triumf.ca&amp;quot; rather than &amp;quot;Sample Frontend@localhost&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Run the Analyzer on Experiment host ===&lt;br /&gt;
Start the analyzer in an xterm on the MIDAS &#039;&#039;experiment host&#039;&#039; &lt;br /&gt;
 &amp;lt;small&amp;gt;[johnfoo@mhostpc e777] $HOME/online/analyzer&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continue by starting a run and dumping the data as described under [[#Frontend and Analyzer (localhost)]].&lt;br /&gt;
&lt;br /&gt;
=== Create experiment startup script ===&lt;br /&gt;
It is useful to create a script that will automatically start all the required clients for the experiment. This is called a startup script (any name can be used). Create  {{Filepath|path=$HOME/online/bin/start_daq.sh}} on the &#039;&#039;experiment host&#039;&#039; as follows, (supply the [[mhttpd]] ports if default is not used) :&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 # start_daq.sh&lt;br /&gt;
 cd $HOME/online&lt;br /&gt;
 #&lt;br /&gt;
 switch (`hostname`)&lt;br /&gt;
   case $MIDAS_HOST*:    ## MIDAS_HOST is assigned in .cshrc (.bashrc)&lt;br /&gt;
      echo &amp;quot;Good, we are on $MIDAS_HOST&amp;quot;&lt;br /&gt;
      breaksw&lt;br /&gt;
   case $REMOTE_HOST*:   ## REMOTE_HOST is assigned in .cshrc (.bashrc)&lt;br /&gt;
      echo &amp;quot;startup script should be executed on $MIDAS_HOST&amp;quot;&lt;br /&gt;
 endsw&lt;br /&gt;
 #&lt;br /&gt;
 odbedit -c clean&lt;br /&gt;
 #   start mhttpd on default port (Mongoose https version)&lt;br /&gt;
 mhttpd  -D   # you can optionally restrict access to localhost and/or other specified hosts - see [[mhttpd]]&lt;br /&gt;
 #   start mserver on default port (use argument -p to use a different port) &lt;br /&gt;
 mserver -D  # start mserver on default port (1175) or a different port using -p option - see [[mserver]]&lt;br /&gt;
             # the port must match that of MIDAS_SERVER_HOST in .cshrc (.bashrc) - see above&lt;br /&gt;
             # access must be specifically allowed - see [[#Grant Remote host access permission||above]]&lt;br /&gt;
 xterm -e ./analyzer &amp;amp;&lt;br /&gt;
 ## start frontend on remote host&lt;br /&gt;
 #ssh $REMOTE_HOST $HOME/online/bin/start_frontend -O &amp;gt;&amp;amp; $HOME/online/bin/start_frontend.log  &amp;amp;&lt;br /&gt;
 mlogger -D&lt;br /&gt;
 #end file&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Note that command to start the frontend on the remote host is commented out. It can be uncommented once the start_frontend script is written and tested.&lt;br /&gt;
&lt;br /&gt;
Shut down any clients that are running already by running odbedit on the MIDAS &#039;&#039;experiment host&#039;&#039; and execute the new startup script   {{File|name=start_daq.sh}} (make it executable if desired)&lt;br /&gt;
 &amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] odbedit&lt;br /&gt;
   [local:e777:S]/&amp;gt;sh all&lt;br /&gt;
   [mhostpc] ./start_daq.sh &amp;lt;/small&amp;gt;&lt;br /&gt;
and check that {{Utility|name=odbedit}} still works on the &#039;&#039;REMOTE host&#039;&#039;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;&lt;br /&gt;
    [rlxhost] odbedit &lt;br /&gt;
    [mhostpc.triumf.ca:1175:e777:Stopped]/&amp;gt;ls &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may wish to modify the script to restart missing clients only.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create script to start frontend ===  &lt;br /&gt;
The startup file  {{File|name=start_daq.sh}}  invoked a script  {{File|name=start_frontend}} to start the remote frontend. This line was commented out (see [[#Create experiment startup script|above]]). Once the frontend is working, create a script to start the frontend (e.g. file {{Filepath|path=$HOME/online/bin/start_frontend}}).&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 #!/bin/tcsh&lt;br /&gt;
 # Script to start frontend running on $REMOTE_HOST&lt;br /&gt;
 #&lt;br /&gt;
 # This script runs on the REMOTE HOST&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;starting frontend for experiment $MIDAS_EXPT_NAME &amp;quot;&lt;br /&gt;
 xterm -geometry 150x50+800+0 -fg white -bg blue -title &amp;quot;Frontend&amp;quot; -e  &amp;quot;$HOME/online/fe_32/frontend&amp;quot; &amp;amp;&lt;br /&gt;
 echo &amp;quot;Frontend task has been started&amp;quot;&lt;br /&gt;
 exit&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Check that this script works by running it on the REMOTE host. If successful, &lt;br /&gt;
run the commented command in an xterm on the &#039;&#039;experiment host&#039;&#039;&lt;br /&gt;
    &amp;lt;small&amp;gt;[mhostpc] ssh $REMOTE_HOST $HOME/online/bin/start_frontend -O &amp;gt;&amp;amp; $HOME/online/bin/start_frontend.log  &amp;amp; &amp;lt;/small&amp;gt;&lt;br /&gt;
This command relies on password-less access set up with SSH keys (see [[#Experimental setup (Remote)]]).&lt;br /&gt;
If successful, uncomment line in {{File|name=start_daq.sh}}, and run the script to check that it can start the remote client(s) from the MIDAS &#039;&#039;experiment host&#039;&#039; (first shutting down all running clients) :&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
    [mhostpc] odbedit -c &amp;quot;sh all&amp;quot;&lt;br /&gt;
    [mhostpc] ./start_daq.sh &amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next [[#Customizing your experiment|customize your experiment]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Customizing your experiment ==&lt;br /&gt;
&lt;br /&gt;
Here are some of the more common options provided for users to customize their experiments according to their own preferences:&lt;br /&gt;
&lt;br /&gt;
; Write frontend(s) to read out and control your hardware&lt;br /&gt;
: Modify the example frontend and Makefile (from $MIDASSYS/examples/) you have already copied and built so it accesses your hardware. &lt;br /&gt;
&lt;br /&gt;
: The example Frontend.c is an example of [[Frontend user code]]. You can find documentation about the frontend structure under [[Frontend Application]], [[Frontend Operation]] and [[Frontend user code]]. You may need to set up some [[Event Notification (Hot-Link)|Hot-Links]] in the frontend. The MIDAS package includes device drivers for some of the more common hardware. See [[MIDAS Driver Library]] for more information.  &lt;br /&gt;
&lt;br /&gt;
; Modify analyzer(s) for your data &lt;br /&gt;
: Modify the example analyzer code as necessary to analyze the data from your frontends.&lt;br /&gt;
&lt;br /&gt;
; Slow Controls &lt;br /&gt;
: Control your slow-controls equipment with slow-control frontend(s) optionally using the [[#MIDAS Package Installation|MSCB]] system. &lt;br /&gt;
&lt;br /&gt;
; Data logger &lt;br /&gt;
: Set up the data logger [[mlogger]] to log data to a storage device. Many options are available - see [[Data Logger]], [[mlogger]] and [[/Logger ODB tree]] for instructions.&lt;br /&gt;
&lt;br /&gt;
; Allow programs to be restarted from the [[Programs Page]] &lt;br /&gt;
: See mhttpd [[Programs Page]] and [[/Programs ODB tree]]&lt;br /&gt;
&lt;br /&gt;
; Write scripts which run at start and end of run &lt;br /&gt;
: See [[/Programs ODB tree#Execute on start run]] and  [[/Programs ODB tree#Execute on stop run]]&lt;br /&gt;
&lt;br /&gt;
; Create a shutdown script &lt;br /&gt;
: Create a script similar to the startup script to shutdown the experiment&lt;br /&gt;
&lt;br /&gt;
; Lazy logger&lt;br /&gt;
: Set up the [[lazylogger]] for archiving data files for storage.&lt;br /&gt;
&lt;br /&gt;
; Create edit-on-start parameters &lt;br /&gt;
: See [[Edit-on-start Parameters]]&lt;br /&gt;
&lt;br /&gt;
; Set up the alarm system &lt;br /&gt;
: See [[Alarm System]] and [[Alarms Page]]&lt;br /&gt;
&lt;br /&gt;
; Set up history system &lt;br /&gt;
: See [[History System]] and [[History Page]]&lt;br /&gt;
&lt;br /&gt;
; Set up the Electronic logbook (Elog) &lt;br /&gt;
: See [[Elog]] for details&lt;br /&gt;
&lt;br /&gt;
; Set up the Sequencer &lt;br /&gt;
: The [[Sequencer Page#Sequencer]] can be used to run a sequence of runs, changing parameters as needed.  &lt;br /&gt;
&lt;br /&gt;
; Write a webserver Custom page &lt;br /&gt;
: To better control and monitor your experiment, you may want to write a [[Custom Page]].&lt;br /&gt;
&lt;br /&gt;
== Start MIDAS on boot ==&lt;br /&gt;
&lt;br /&gt;
To start MIDAS mhttpd, mlogger and elogd at boot time, add following cron entries:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[iris@iris00 ~]$ crontab -l&lt;br /&gt;
@reboot /home/iris/packages/midas/bin/mhttpd -D&lt;br /&gt;
@reboot /home/iris/packages/midas/bin/mlogger -D&lt;br /&gt;
@reboot /home/iris/packages/elog/elogd -c /home/iris/packages/elog/elogd.cfgiris -D&lt;br /&gt;
[iris@iris00 ~]$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Quickstart_Linux&amp;diff=3642</id>
		<title>Quickstart Linux</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Quickstart_Linux&amp;diff=3642"/>
		<updated>2026-09-29T16:17:02Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* ROOTANA Package Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This quickstart shows you how to install the MIDAS packages on a linux box and create a &#039;&#039;&#039;MIDAS experiment&#039;&#039;&#039;. &lt;br /&gt;
The linux box will be called the MIDAS &#039;&#039;&#039;&#039;&#039;experiment host&#039;&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
Log on to the &#039;&#039;[[#Introduction|Experiment Host]]&#039;&#039; and decide on a name for the MIDAS experiment (the &#039;&#039;experiment name&#039;&#039;).&lt;br /&gt;
In these instructions, the MIDAS packages and experiment will be installed under the username &amp;quot;johnfoo&amp;quot;. &lt;br /&gt;
The ODB and other shared memory buffers for the MIDAS experiment will reside on the &#039;&#039;experiment host&#039;&#039; (localhost).&lt;br /&gt;
MIDAS and the other required packages will be installed under directory  {{Filepath|path=$HOME/packages}}. The MIDAS &#039;&#039;experiment directory&#039;&#039; will be  {{Filepath|path=$HOME/online}} and the MIDAS &#039;&#039;experiment name&#039;&#039; will be &amp;quot;e777&amp;quot;. The name of the &#039;&#039;experiment host&#039;&#039; will be &amp;quot;mhostpc&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
;NOTE&lt;br /&gt;
: The user should substitute directory paths for the MIDAS packages and experiment directory as required, and names for &#039;&#039;experiment host&#039;&#039;, username, &#039;&#039;experiment name&#039;&#039; appropriate to his/her own setup.&lt;br /&gt;
&lt;br /&gt;
== Experimental setup ==&lt;br /&gt;
These instructions describe setting up an experiment that will run ONLY on the MIDAS &#039;&#039;experiment host&#039;&#039; computer (i.e. &#039;&#039;&#039;localhost only&#039;&#039;&#039;). In this case, the MIDAS &#039;&#039;experiment host&#039;&#039; has access to any hardware required, and all frontends, logger, analyzer etc. run on the one computer. &lt;br /&gt;
&lt;br /&gt;
Modifications to run an experiment with additional frontend(s) running &#039;&#039;&#039;remotely&#039;&#039;&#039; (i.e. on remote cpu(s)) will also be described.&lt;br /&gt;
Follow the instructions for setting up a localhost-only experiment until indicated. &lt;br /&gt;
 &lt;br /&gt;
In both cases, the main MIDAS applications (e.g. [[mlogger]], [[mhttpd]]) run on the MIDAS &#039;&#039;experiment host&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Environment Variables==&lt;br /&gt;
The following Environment variables should to be added to the  {{File|name=.cshrc}} or {{File|name=.bashrc}} file (depending on your shell) in the {{Filepath|path=$HOME}} directory on the &#039;&#039;experiment host&#039;&#039;,  so that they will be defined at login. &#039;&#039;&#039;Substitute appropriate values for your own setup&#039;&#039;&#039;. &lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! csh  !! bash !! comment&lt;br /&gt;
|-&lt;br /&gt;
| setenv MIDASSYS $HOME/packages/midas ||  export MIDASSYS=$HOME/packages/midas ||Base directory of the MIDAS package&lt;br /&gt;
|-&lt;br /&gt;
| setenv MIDAS_EXPTAB $HOME/online/exptab || export MIDAS_EXPTAB=$HOME/online/exptab  || MIDAS experiment table &lt;br /&gt;
|-&lt;br /&gt;
| setenv MIDAS_EXPT_NAME e777  || export MIDAS_EXPT_NAME=e777  || MIDAS experiment name&lt;br /&gt;
|-&lt;br /&gt;
| setenv PATH .:$MIDASSYS/bin:$PATH  || export PATH=$PATH:$MIDASSYS/bin || path&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Logout and login again, or source {{File|name=.cshrc}} (source {{File|name=.bashrc}}) for the changes to take effect.&lt;br /&gt;
;NOTE&lt;br /&gt;
: See [[MIDAS environment variables]] for a list of environment variables used by MIDAS.&lt;br /&gt;
&lt;br /&gt;
== ROOT Package Installation ==&lt;br /&gt;
MIDAS has optional integration with [https://root.cern.ch ROOT]. ROOT is not required for acquiring data or storing it in midas files, but is used by some of the analysis tools (including the example analyzer that will be built later in this Quickstart). It is also possible to write midas data directly to ROOT files if desired.&lt;br /&gt;
&lt;br /&gt;
If you require ROOT integration, follow the installation instructions on the [https://root.cern.ch ROOT website] and set the ROOTSYS environment variable.&lt;br /&gt;
&lt;br /&gt;
If you do not require ROOT integration, leave the ROOTSYS variable undefined.&lt;br /&gt;
&lt;br /&gt;
== Adding SSL support ==&lt;br /&gt;
&lt;br /&gt;
We recommend running mhttpd (the MIDAS web server) behind an industry-grade web proxy like apache httpd or nginx. httpd/nginx will then handle the SSL security. It is however also possible to build mhttpd with built-in SSL support. See [[Mhttpd|the mhttpd documentation]] for more details about web security.&lt;br /&gt;
&lt;br /&gt;
If you wish to enable SSL support in mhttpd itself:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
  [mhostpc] cd $MIDASSYS&lt;br /&gt;
  [mhostpc] make mbedtls&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MIDAS Package Installation ==&lt;br /&gt;
The MIDAS package will be installed on the &#039;&#039;experiment host&#039;&#039; in the directory given by MIDASSYS - see [[#Environment Variables]].&lt;br /&gt;
&lt;br /&gt;
Install the MIDAS and other package(s) from the MIDAS git repository in an xterm as follows:&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] mkdir $HOME/packages&lt;br /&gt;
   [mhostpc] cd $HOME/packages&lt;br /&gt;
   [mhostpc] git clone https://gitlab.triumf.ca/midas/midas.git --recurse-submodules&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already cloned MIDAS and forgot the &amp;quot;--recurse-submodules&amp;quot;, you can do a &amp;quot;git submodule update --init --recursive&amp;quot; later. If you want to pull MIDAS later to update to the current version, you need either &amp;quot;git pull --recurse-submodules&amp;quot;. To tell git to always recurse, you can set a global flag via &amp;quot;git config submodule.recurse true&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The MIDAS Makefile will auto-detect whether MSCB, ROOT, MYSQL, SQLITE, ODBC etc. are available (or have been installed). If you need these features, make sure they are available before building the MIDAS package.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] cd $MIDASSYS&lt;br /&gt;
   [mhostpc] mkdir build&lt;br /&gt;
   [mhostpc] cd build&lt;br /&gt;
   [mhostpc] cmake ..                  ### configure build process (see note below about cmake/cmake3)&lt;br /&gt;
   [mhostpc] make install              ### build and install midas to bin/ and lib/ directories&lt;br /&gt;
   [mhostpc] cd ..&lt;br /&gt;
   [mhostpc] ls -l bin/odbedit         ### check that odbedit has been created (do not run it yet)&lt;br /&gt;
&amp;lt;/small&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
MIDAS requires cmake version 3.10 or later. On some systems, you have to call &amp;quot;cmake3 ..&amp;quot;, on others just &amp;quot;cmake ..&amp;quot;. Some systems might require you to install cmake first (see the [https://cmake.org/download/ cmake website; installation is very simple).&lt;br /&gt;
&lt;br /&gt;
In case of problems see &lt;br /&gt;
* [[Installation#Installing MIDAS|gitlab is down]] or &lt;br /&gt;
* [[Installation/Compilation problems#SSL certificate errors|SSL certificate errors]].&lt;br /&gt;
&lt;br /&gt;
==ROOTANA Package Installation==&lt;br /&gt;
&lt;br /&gt;
rootana is an optional framework for analyzing midas data in realtime and displaying plots (either by a graphical interface or via webpages). Most of the features are now available in manalyzer, which is included in the base midas install.&lt;br /&gt;
&lt;br /&gt;
If you require the legacy ROOTANA package, you can install it with:&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
    [mhostpc] cd $HOME/packages&lt;br /&gt;
    [mhostpc] git clone https://gitlab.triumf.ca/midas/rootana.git&lt;br /&gt;
    [mhostpc] cd rootana&lt;br /&gt;
    [mhostpc] make&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
add ROOTANASYS=$HOME/packages/rootana to the login file.&lt;br /&gt;
&lt;br /&gt;
Install the JSROOT package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd $HOME/packages&lt;br /&gt;
git clone https://github.com/linev/jsroot.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
add JSROOTSYS=$HOME/packages/jsroot to the login file.&lt;br /&gt;
&lt;br /&gt;
==ROODY Package Installation==&lt;br /&gt;
&lt;br /&gt;
ROODY is a legacy package for displaying live ROOT histograms. It is generally not used by new experiments.&lt;br /&gt;
&lt;br /&gt;
If ROODY is needed,&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
    [mhostpc] cd $HOME/packages&lt;br /&gt;
    [mhostpc] git clone https://bitbucket.org/tmidas/roody&lt;br /&gt;
    [mhostpc] cd roody&lt;br /&gt;
    [mhostpc] make&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create the Experiment file exptab ==&lt;br /&gt;
In this example, the experimental directory is {{Filepath|path=$HOME/online}}. Create this directory on the &#039;&#039;experiment host&#039;&#039; (localhost):&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] mkdir $HOME/online&lt;br /&gt;
   [mhostpc] cd $HOME/online&amp;lt;/small&amp;gt;&lt;br /&gt;
Then create the [[exptab]] file {{Filepath|path=$HOME/online/exptab}} containing the three parameters:&lt;br /&gt;
# the experiment name &lt;br /&gt;
# location of MIDAS shared memory buffers&lt;br /&gt;
# username&lt;br /&gt;
as follows (using parameters for your own experiment):&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] cat &amp;gt; exptab&lt;br /&gt;
    e777 /home/johnfoo/online johnfoo&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The path of the  {{File|name=exptab}} file is given by MIDAS_EXPTAB - see [[#Environment Variables]].&lt;br /&gt;
&lt;br /&gt;
== Create shared memory files  ==&lt;br /&gt;
At this point you should be able to run [[odbedit]] on the &#039;&#039;experiment host&#039;&#039; (localhost). The first time  {{Utility|name=odbedit}} is run, it will create the required  {{File|name=.*.SHM}} files  in the MIDAS experiment directory  {{Filepath|path=$HOME/online}}. These are the saved files for the MIDAS shared memory.&lt;br /&gt;
&lt;br /&gt;
The default directory  {{Filepath|path=$HOME/online}} will contain the MIDAS messages file ({{File|name=midas.log}}) and&lt;br /&gt;
any data files you may create. If you want an alternative location for the data files see [[#Customizing your experiment]].&lt;br /&gt;
  &lt;br /&gt;
Run {{Utility|name=odbedit}}, and type {{Odbedit cmd|cmd=ls}} to list the default directories. &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] odbedit&lt;br /&gt;
 [local:e777:S]/&amp;gt;ls&lt;br /&gt;
 Experiment&lt;br /&gt;
 System&lt;br /&gt;
 Programs&lt;br /&gt;
 Logger&lt;br /&gt;
 Runinfo&lt;br /&gt;
 Alarms&amp;lt;/small&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
== Run the MIDAS Web Server ==&lt;br /&gt;
&lt;br /&gt;
=== Using apache ===&lt;br /&gt;
&lt;br /&gt;
Recommended for production systems with maximum security is to run mhttpd behind an industry-standard SSL/https proxy with password protection. We document instructions for apache here, but you could nginx instead.&lt;br /&gt;
&lt;br /&gt;
To do this using apache httpd on CentOS-7, do this:&lt;br /&gt;
* configure apache httpd per instructions for [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog Ubuntu] or [https://daq00.triumf.ca/DaqWiki/index.php/SLinstall#Configure_HTTPS_server_.28CentOS7.29 CentOS 7]&lt;br /&gt;
* run mhttpd&lt;br /&gt;
* use web browser to connect to https://mhostpc/&lt;br /&gt;
* enter the user name and password configured in apache httpd&lt;br /&gt;
* the midas status page should open&lt;br /&gt;
&lt;br /&gt;
=== Standalone (less secure) ===&lt;br /&gt;
&lt;br /&gt;
For simplified installation, one can use standalone mhttpd with built-in https and password protection. This configuration&lt;br /&gt;
is only as secure as the underlying mongoose and OpenSSL web server and encryption packages. Use the odbedit tool to edit settings in the [[Webserver_ODB_tree|Webserver ODB tree]]:&lt;br /&gt;
&lt;br /&gt;
* Set &amp;quot;Enable https port&amp;quot; to &amp;quot;y&amp;quot;&lt;br /&gt;
* Set &amp;quot;https port passwords&amp;quot; to &amp;quot;y&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Many current operating systems implement a built-in firewall which will block outside access to mhttpd. See instructions for [https://daq00.triumf.ca/DaqWiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29 CentOS 7].&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;
&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:13880: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:13881:mongoose,ERROR] please create password file: touch /home/johnfoo/online/htpasswd.txt&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:13818:mongoose,ERROR] mongoose web server password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot; has no passwords for realm &amp;quot;exptname&amp;quot;&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:13819:mongoose,ERROR] please add passwords by running: htdigest /home/johnfoo/online/htpasswd.txt exptname midas&lt;br /&gt;
  mongoose_init: Error: Cannot initialize authorization object!&lt;br /&gt;
  Error: Could not start the mongoose web server, see messages and midas.log, bye!&lt;br /&gt;
&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. (htdigest is part of the httpd-tools package)&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;
&lt;br /&gt;
Run {{Utility|name=mhttpd}} again.&lt;br /&gt;
&lt;br /&gt;
If you get error messages like &amp;lt;small&amp;gt;&amp;lt;code&amp;gt;https port &amp;quot;[::]:8443&amp;quot; requested, but mhttpd compiled without MG_ENABLE_SSL&amp;lt;/code&amp;gt;&amp;lt;/small&amp;gt; then you need to re-compile MIDAS after [[Mhttpd#Build_mhttpd_with_SSL_support|adding SSL support]].&lt;br /&gt;
&lt;br /&gt;
Otherwise, you will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;&lt;br /&gt;
  HTTP Digest authentication with realm &amp;quot;exptname&amp;quot; and password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot;&lt;br /&gt;
  Hostlist off, connections from anywhere will be accepted&lt;br /&gt;
  Listening on &amp;quot;http://localhost:8080&amp;quot;, passwords OFF, hostlist OFF&lt;br /&gt;
  Listening on &amp;quot;http://[::1]:8080&amp;quot;, passwords OFF, hostlist OFF&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:15739:mongoose_listen,ERROR] cannot find SSL certificate file &amp;quot;/home/johnfoo/online/ssl_cert.pem&amp;quot;&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:15740:mongoose_listen,ERROR] please create SSL certificate file using openssl: cd $MIDASSYS; openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key -subj &amp;quot;/C=/ST=/L=/O=midas/OU=mhttpd/CN=localhost&amp;quot;; 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;
  [mhttpd,ERROR] [mhttpd.cxx:15741:mongoose_listen,ERROR] or using certbot (recommened): setup certbot per Let&#039;s Encrypt instructions, certificates are typically saved in /etc/letsencrypt/live/$HOSTNAME/, copy fullchain.pem and privkey.pem to $MIDASSYS; cd $MIDASSYS; cat fullchain.pem privkey.pem &amp;gt; ssl_cert.pem&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:15918:mongoose_init,ERROR] Failed to listen on a TCP port enabled in ODB /WebServer&lt;br /&gt;
  Error: Could not start the mongoose web server, see messages and midas.log, bye!&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a self-signed certificate suitable for initial testing by executing the commands printed by mhttpd.&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/https proxy (apache httpd).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now restart  {{Utility|name=mhttpd}}&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&lt;br /&gt;
 HTTP Digest authentication with realm &amp;quot;test_pol&amp;quot; and password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot;&lt;br /&gt;
 Hostlist off, connections from anywhere will be accepted&lt;br /&gt;
 Listening on &amp;quot;http://localhost:8080&amp;quot;, passwords OFF, hostlist OFF&lt;br /&gt;
 Listening on &amp;quot;http://[::1]:8080&amp;quot;, passwords OFF, hostlist OFF&lt;br /&gt;
 Mongoose web server will use https certificate file &amp;quot;./ssl_cert.pem&amp;quot;&lt;br /&gt;
 Listening on &amp;quot;https://[::]:8443&amp;quot;, passwords enabled, hostlist OFF&lt;br /&gt;
 Mongoose web server is using 1 threads&lt;br /&gt;
 Mongoose web server is using 2 threads&lt;br /&gt;
 Mongoose web server is using 3 threads&lt;br /&gt;
 Mongoose web server is using 4 threads&amp;lt;/small&amp;gt;&lt;br /&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;
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]]. To use some other ports, change the relevant values in the [[Webserver_ODB_tree|Webserver ODB tree]].&lt;br /&gt;
&lt;br /&gt;
== Run the MIDAS logger ==&lt;br /&gt;
Start the MIDAS logger [[mlogger]] on the &#039;&#039;experiment host&#039;&#039; (localhost) :&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mlogger&amp;lt;/small&amp;gt; &lt;br /&gt;
This should start without error. It is usually run as a daemon, however in this case it is run in a terminal to check for errors. Starting the midas logger [[mlogger]] will automatically create more keys in the  {{Odbpath|path=/Logger}} ODB tree.&lt;br /&gt;
&lt;br /&gt;
From the MIDAS status page, go to the &amp;quot;Programs&amp;quot; page, then the &amp;quot;Logger&amp;quot; page and set ODB variables:&lt;br /&gt;
* Required -&amp;gt; set to &amp;quot;y&amp;quot;&lt;br /&gt;
* Start command -&amp;gt; set to &amp;quot;mlogger -D&amp;quot;&lt;br /&gt;
* Alarm Class -&amp;gt; set to &amp;quot;Alarm&amp;quot;&lt;br /&gt;
&lt;br /&gt;
To test this, go to the &amp;quot;Programs&amp;quot; page, press &amp;quot;stop logger&amp;quot;, then &amp;quot;start logger&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Start a run, wait 10 seconds, stop the run.&lt;br /&gt;
&lt;br /&gt;
From the MIDAS &amp;quot;Status&amp;quot; page, go to the &amp;quot;logging channels -&amp;gt; channel #0&amp;quot; and set ODB variables:&lt;br /&gt;
* Output -&amp;gt; &amp;quot;FILE&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Start a run, go to the &amp;quot;Status&amp;quot; page, observe that the output file is written with lz4 compression and has the &amp;quot;mid.lz4&amp;quot; extension.&lt;br /&gt;
&lt;br /&gt;
Stop the run.&lt;br /&gt;
&lt;br /&gt;
== Run test frontend ==&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;fetest&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the MIDAS &amp;quot;Status&amp;quot; page there will be 5 new equipment entries:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Equipment created by the fetest program&lt;br /&gt;
|-&lt;br /&gt;
! Equipment name !! Data it sends !! How often data is sent&lt;br /&gt;
|-&lt;br /&gt;
| test_random || Random data banks || 1Hz&lt;br /&gt;
|-&lt;br /&gt;
| test_slow || Example slow control data for testing the midas history plots || 1Hz, even when a run isn&#039;t in progress&lt;br /&gt;
|-&lt;br /&gt;
| test_rare || Data that look like a sine wave || 0.1Hz, even when a run isn&#039;t in progress&lt;br /&gt;
|-&lt;br /&gt;
| test_bulk || Large events || 1Hz&lt;br /&gt;
|-&lt;br /&gt;
| test_rpc || None. It shows an example of a &amp;quot;remote procedure call&amp;quot; (RPC) handler. Javascript/C++/Python code can connect to the program, and it will respond with the current time (in this toy example) || never&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note the event counters for test_slow and test_rare are already incrementing.&lt;br /&gt;
&lt;br /&gt;
Start a run.&lt;br /&gt;
&lt;br /&gt;
Observe that the event counters for test_bulk and test_random are also incrementing now, and that the output data file size is growing.&lt;br /&gt;
&lt;br /&gt;
Click on the &amp;quot;Event dump&amp;quot; page and then the &amp;quot;Run&amp;quot; button. You&#039;ll see the raw data that is being written to disk. (The data from most of the equipment is double-precision floating point numbers; the data from the &amp;quot;bulk&amp;quot; equipment is just a bunch of zeros).&lt;br /&gt;
&lt;br /&gt;
Return the status page and stop the run.&lt;br /&gt;
&lt;br /&gt;
== Create a history plot ==&lt;br /&gt;
&lt;br /&gt;
Go to the MIDAS &amp;quot;History&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Say &amp;quot;new&amp;quot;, panel name &amp;quot;test&amp;quot;. In the history editor select event &amp;quot;test_slow&amp;quot;, and click the &amp;quot;save&amp;quot; button (you can ignore the rest of the options for now). If the &amp;quot;test_slow&amp;quot; event isn&#039;t listed, make sure that the mlogger program is running, as described above.&lt;br /&gt;
&lt;br /&gt;
History plot &amp;quot;test&amp;quot; should open with a sine-wave plot. Data on the plot should update as long as &amp;quot;fetest&amp;quot; is running (there is no need to start a run).&lt;br /&gt;
&lt;br /&gt;
== Clients run on Localhost only ==&lt;br /&gt;
;NOTE: &lt;br /&gt;
* If creating a MIDAS experiment with a &#039;&#039;&#039;REMOTE&#039;&#039;&#039; frontend, &#039;&#039;&#039;continue by following the instructions&#039;&#039;&#039; [[#Running with one or more REMOTE frontends]].&lt;br /&gt;
* If all clients are running on the Experiment Host (i.e. &#039;&#039;&#039;localhost&#039;&#039;&#039;), continue with the following instructions:&lt;br /&gt;
&lt;br /&gt;
=== Frontend and Analyzer (localhost) ===&lt;br /&gt;
&lt;br /&gt;
THIS SECTION IS VERY OBSOLETE&lt;br /&gt;
&lt;br /&gt;
There are several examples of [[Frontend user code]] ({{File|name=frontend.c}}) in the MIDAS package available under {{Filepath|path=$MIDASSYS/examples/}}. Choose a suitable example from this directory that you can later modify for your own particular setup (e.g. for a slow control, choose the {{Filepath|path=../slowcont/}} example). &lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;frontend&#039;&#039;&#039; is a program that usually reads data from the hardware and sends it to a buffer to be logged and analyzed. You can find documentation about the frontend structure under [[Frontend Application]], [[Frontend Operation]] and [[Frontend user code]].&lt;br /&gt;
&lt;br /&gt;
The example chosen here is from  {{Filepath|path=$MIDASSYS/examples/experiment/}}. It does &#039;&#039;&#039;not need any hardware&#039;&#039;&#039; and produces simulated events.  &lt;br /&gt;
&lt;br /&gt;
On the MIDAS &#039;&#039;experiment host&#039;&#039; (localhost), copy the example to the experiment directory and build it.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
      [mhostpc] cd $HOME/online&lt;br /&gt;
      [mhostpc] cp $MIDASSYS/examples/experiment/* .&lt;br /&gt;
      [mhostpc] make&amp;lt;/small&amp;gt;&lt;br /&gt;
The analyzer will only build if ROOT has previously been installed.&lt;br /&gt;
At this point the frontend and the analyzer should be ready if no errors were generated during the build. Try the frontend and analyzer by starting them in xterms. &lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
      [mhostpc] frontend&lt;br /&gt;
      [mhostpc] analyzer&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Equipment ODB tree ===&lt;br /&gt;
Starting the frontend will automatically create the  {{Odbpath|path=/Equipment}} ODB tree and one or more equipments. In this case, the equipments &amp;quot;trigger&amp;quot; and &amp;quot;scaler&amp;quot; have been defined by code in  {{File|name=frontend.c}} and created the first time frontend runs.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
     [mhostpc] odbedit&lt;br /&gt;
     [local:e777:S]/&amp;gt;ls /equipment&lt;br /&gt;
     Trigger                         &lt;br /&gt;
     Scaler  &amp;lt;/small&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
View the MIDAS main status web page (by pointing your browser to https://localhost:8443/ or appropriate port if not using the default).&lt;br /&gt;
Observe on the [[Status Page]] that the two Equipments (Trigger, Scaler) have appeared in the Equipment section (Figure 1) and are coloured green.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Click thumbnail to enlarge&#039;&#039;&#039;&lt;br /&gt;
[[File:quickstart_status_page.png|thumb|left|Figure 1: web server status page showing example frontend equipments]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;clear: both&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;  &amp;lt;!-- clear wraparound after thumbnail --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rather than using odbedit,  you can view the contents of these equipments by clicking on the ODB button, then on {{Odbpath|path=/Equipment}}, then {{Odbpath|path=Trigger}} or {{Odbpath|path=Scaler}}. See [[ODB Page]] for more information.&lt;br /&gt;
&lt;br /&gt;
=== Start a run ===&lt;br /&gt;
Start a run by pressing the Start button on the [[Status Page]].&lt;br /&gt;
The Equipment display on the Status Page will now show some event statistics (Figure 2)&lt;br /&gt;
&#039;&#039;&#039;Click thumbnail to enlarge&#039;&#039;&#039;&lt;br /&gt;
[[File:sample_frontend_status.png|thumb|left|Figure 2: Equipments shown on Status Page showing event statistics]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;clear: both&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;  &amp;lt;!-- clear wraparound after thumbnail --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The frontend will show an event display that will update when a run is started, e.g.&lt;br /&gt;
&lt;br /&gt;
 Sample Frontend connected to &amp;lt;local&amp;gt;. Press &amp;quot;!&amp;quot; to exit      18:48:2546:08&lt;br /&gt;
 ==========================================================================&lt;br /&gt;
 Run status:   Running    Run number 2                                   |/   /&lt;br /&gt;
 ===========================================================================&lt;br /&gt;
 Equipment     Status     Events     Events/sec Rate[B/s]  ODB-&amp;gt;FE FE-&amp;gt;OD&lt;br /&gt;
 ---------------------------------------------------------------------------&lt;br /&gt;
 Trigger       OK         13948      99.0       5413.0     0          140         &lt;br /&gt;
 Scaler        OK         15         0.3         15.4      0          15    &lt;br /&gt;
&lt;br /&gt;
The [[Status Page]] will also show events being generated (click the refresh button if necessary). &lt;br /&gt;
&lt;br /&gt;
=== Event Dump ===&lt;br /&gt;
While a run is in progress, the midas application [[mdump]] will provide you an event dump of the collected data from the running frontend, e.g.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
  mhostpc&amp;gt; mdump -l 50&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:whitesmoke&amp;quot;&amp;gt;blank&amp;lt;/span&amp;gt;&lt;br /&gt;
 - MIDAS revision: Mon Nov 2 11:50:51 2015 -0800 - 3b66779 -- Enter &amp;lt;!&amp;gt; to Exit ------- Midas Dump ---&lt;br /&gt;
 ------------------------ Event# 1 ------------------------&lt;br /&gt;
 Evid:0001- Mask:0000- Serial:0- Time:0x567a0c5d- Dsize:40/0x28&lt;br /&gt;
 #banks:2 - Bank list:-ADC0TDC0-&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:whitesmoke&amp;quot;&amp;gt;blank&amp;lt;/span&amp;gt;&lt;br /&gt;
 Bank:ADC0 Length: 8(I*1)/2(I*4)/4(Type) Type:Unsigned Integer*2&lt;br /&gt;
   1-&amp;gt; 0x0167 0x03c6 0x0069 0x0073 &lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:whitesmoke&amp;quot;&amp;gt;blank&amp;lt;/span&amp;gt;&lt;br /&gt;
 Bank:TDC0 Length: 8(I*1)/2(I*4)/4(Type) Type:Unsigned Integer*2&lt;br /&gt;
   1-&amp;gt; 0x0051 0x00ff 0x004a 0x00ec &lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
For further data processing/analysis, either the midas analyzer or the rootana can used for data display as well. &lt;br /&gt;
&lt;br /&gt;
=== Create a startup script (localhost) ===&lt;br /&gt;
It is useful to create a script that will automatically start all the required clients for the experiment. This is called a startup script. Here, the startup script will be  {{File|name=start_daq.sh}} (any name can be used). Create  {{Filepath|path=$HOME/online/bin/start_daq.sh}} on the &#039;&#039;experiment host&#039;&#039; as follows (supply the [[mhttpd]] ports if default is not used):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;small&amp;gt;#!/bin/sh&lt;br /&gt;
 # start_daq.sh&lt;br /&gt;
 cd $HOME/online&lt;br /&gt;
 odbedit -c clean&lt;br /&gt;
 #   start mhttpd on default port. (Mongoose https version)&lt;br /&gt;
 mhttpd  -D  # you can optionally restrict access to localhost and other specified hosts - see [[mhttpd]]&lt;br /&gt;
 xterm -e ./frontend &amp;amp;&lt;br /&gt;
 xterm -e ./analyzer &amp;amp;&lt;br /&gt;
 mlogger -D&lt;br /&gt;
 #end file&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before running this script, you will need to shutdown any running clients:&lt;br /&gt;
 &amp;lt;small&amp;gt;mhostpc&amp;gt; odbedit -c &amp;quot;sh all&amp;quot;&amp;lt;/small&amp;gt;&lt;br /&gt;
or you can use the  {{Utility|name=mhttpd}} [[Programs Page]] to shut them down.&lt;br /&gt;
&lt;br /&gt;
The script will start them as daemons. &lt;br /&gt;
By running the startup script start_daq.sh, several MIDAS applications will be started in sequence:&lt;br /&gt;
# Cleanup previous MIDAS application (if any).&lt;br /&gt;
# Start the MIDAS web server [mhttpd]&lt;br /&gt;
# Start the frontend application in its own xterm (for debugging purpose).&lt;br /&gt;
# Start the analyzer application in its own xterm (for debugging purpose).&lt;br /&gt;
# Start the MIDAS Data logger [mlogger]&lt;br /&gt;
  &amp;lt;small&amp;gt;[mhostpc] sh ./start_daq&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may wish to modify the script to restart missing clients only. &lt;br /&gt;
&lt;br /&gt;
Next [[#Customizing your experiment|customize your experiment]].&lt;br /&gt;
&lt;br /&gt;
== Running with one or more REMOTE frontends ==&lt;br /&gt;
These instructions assume you have already followed the instructions to setup an experiment running on the MIDAS experiment host (localhost), i.e. you have setup the MIDAS Environment variables, downloaded MIDAS packages, setup the [[mhttpd]] password and have {{Utility|name=mhttpd}} running successfully.&lt;br /&gt;
&lt;br /&gt;
In the case of &#039;&#039;&#039;remote&#039;&#039;&#039; frontend(s), the remote cpu(s) typically have access to some or all of the hardware. They might be VMIC cpus running in VME crates for example, connected to the MIDAS Host via Ethernet.  They read data from the hardware and send it back to the MIDAS &#039;&#039;experiment host&#039;&#039; to be logged and analyzed.&lt;br /&gt;
&lt;br /&gt;
=== Experimental setup (Remote) ===&lt;br /&gt;
These instructions assume that the MIDAS &#039;&#039;experiment host&#039;&#039; computer is 64-bit (if not see [[#Build 32-bit MIDAS libraries|note below]]), and there is one &#039;&#039;remote host&#039;&#039;, a 32-bit machine named &amp;quot;rlxhost&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;remote host&#039;&#039; mounts the {{Filepath|path=/home}} disk of the &#039;&#039;experiment host&#039;&#039;, so that it &#039;&#039;&#039;has access to the MIDAS packages&#039;&#039;&#039;, the {{Filepath|path=$HOME/online}} directory and shares the .cshrc (or .bashrc) script. It is convenient to set up ssh keys (use ssh-keygen) so that the &#039;&#039;remote host&#039;&#039; can be accessed without supplying the password from the &#039;&#039;experiment host&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If your setup is different, you will have to make changes as appropriate.  &lt;br /&gt;
&lt;br /&gt;
=== Build 32-bit MIDAS libraries ===&lt;br /&gt;
NOTE&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:40px;margin-right:40px;&amp;quot;&amp;gt;&lt;br /&gt;
If the MIDAS &#039;&#039;experiment host&#039;&#039; computer is 32-bit (i.e. the same as the &#039;&#039;remote host&#039;&#039;), which is a simpler setup, you will have built the 32-bit MIDAS libraries already, and can skip the rest of this section. Note however, that in the .cshrc file in the  [[#Modify .cshrc (.bashrc) for Remote host|following section]] you will not need the lines starting &amp;quot;# select 64-bit or 32-bit MIDAS and ROOT&amp;quot;.  The PATH should contain &amp;lt;span style=&amp;quot;color:#214200; font-weight:normal; font-style:italic&amp;quot;&amp;gt;$MIDASSYS/bin&amp;lt;/span&amp;gt; on both experiment host and remote host. This will point to the 32-bit MIDAS libraries. &lt;br /&gt;
------------------------------&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Assuming the MIDAS host computer is 64-bit, you will have already built the 64-bit MIDAS libraries.&lt;br /&gt;
In this case, if the remote frontend is 32-bit, you will need to build the 32-bit MIDAS libraries on the 64-bit machine, i.e.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
    [mhostpc] cd /home/packages/midas&lt;br /&gt;
    [mhostpc] make linux32                ### build the 32-bit MIDAS libraries on 64-bit machine&lt;br /&gt;
    [mhostpc] ls -l linux-m32/bin/odbedit ### check that the 32-bit odbedit has been created &amp;lt;/small&amp;gt;&lt;br /&gt;
Do not run  {{Utility|name=odbedit}} yet on the &#039;&#039;remote host&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If the &amp;quot;make linux32&amp;quot; command fails, you may need to install 32bit support for your compiler (e.g. &amp;quot;apt install g++-multilib&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
=== Modify .cshrc (.bashrc) for Remote host ===&lt;br /&gt;
Add the following to the {{File|name=.cshrc}} (modified appropriately if using {{File|name=.bashrc}}).  When running with a REMOTE Host, the application [[mserver]] will be started (using a particular port) on the MIDAS &#039;&#039;experiment host&#039;&#039; machine only.  Note that the environment variable MIDAS_SERVER_HOST is defined on the remote machine(s) but NOT on the &#039;&#039;experiment host&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
If ROOT has been installed properly and the script &amp;lt;ROOT installation directory&amp;gt;/bin/thisroot.sh is called from .cshrc or .bashrc, the ROOTSYS environment variable should be defined and the ROOT bin directory should be in the PATH environment variable. Make sure that this is the case.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 # setenv MIDAS_HOST mhostpc   # substitute your experiment host name&lt;br /&gt;
 # setenv REMOTE_HOST rlxhost  # substitute your remote host name&lt;br /&gt;
 # setup the MIDAS mserver host&lt;br /&gt;
 #&lt;br /&gt;
 switch (`hostname`)&lt;br /&gt;
 case $MIDAS_HOST*:                &lt;br /&gt;
   unsetenv MIDAS_SERVER_HOST     ## MIDAS_SERVER_HOST not defined&lt;br /&gt;
   breaksw&lt;br /&gt;
 default:&lt;br /&gt;
 setenv MIDAS_SERVER_HOST $MIDAS_HOST.triumf.ca:1175  ## for remote host, define MIDAS_SERVER_HOST, use your domain here&lt;br /&gt;
                                                      ## as hostname + domain name + default mserver port&lt;br /&gt;
                                                      ## port must match that of [[mserver]] used in start_daq.sh &lt;br /&gt;
 endsw&lt;br /&gt;
 #&lt;br /&gt;
 # select 64-bit or 32-bit MIDAS&lt;br /&gt;
 #&lt;br /&gt;
 switch (`uname -i`)&lt;br /&gt;
 case i386:&lt;br /&gt;
   setenv PATH .:$MIDASSYS/linux-m32/bin:$PATH&lt;br /&gt;
   breaksw&lt;br /&gt;
 default:&lt;br /&gt;
   setenv PATH .:$MIDASSYS/linux/bin:$PATH&lt;br /&gt;
 endsw&lt;br /&gt;
 #&lt;br /&gt;
 setenv PATH .:$HOME/online/bin:$HOME/packages/roody/bin:$PATH&lt;br /&gt;
 #&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
After executing {{File|name=.cshrc}} (or {{File|name=.bashrc}}) or logging out, on the MIDAS host (mhostpc) make sure environment variable MIDAS_SERVER_HOST is NOT defined&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] echo $MIDAS_SERVER_HOST&lt;br /&gt;
 [mhostpc] MIDAS_SERVER_HOST: Undefined variable.&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and on the  &#039;&#039;&#039;&#039;&#039;remote host&#039;&#039;&#039;&#039;&#039;, make sure MIDAS_SERVER_HOST IS defined: &lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] echo $MIDAS_SERVER_HOST&lt;br /&gt;
  [rlxhost] MIDAS_SERVER_HOST&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also on the &#039;&#039;remote host&#039;&#039;, make sure that the correct (32-bit)  {{Utility|name=odbedit}} will be used (do not run it yet!)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] which odbedit&lt;br /&gt;
 /home/johnfoo/packages/midas/linux-m32/bin/odbedit&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Grant Remote host access permission === &lt;br /&gt;
Give permission for the remote host(s) to access the experiment by following the instructions to [[Security#MIDAS programs on remote machines|allow MIDAS programs on remote machines]].  If the MIDAS web server [[mhttpd]] is running, use [[ODB Page]] to edit the ODB keys listed, otherwise use [[odbedit]] on the &#039;&#039;experiment host&#039;&#039; machine.&lt;br /&gt;
 &lt;br /&gt;
=== Start mserver on Experiment Host ===&lt;br /&gt;
The application [[mserver]] is not required when running an experiment on the &#039;&#039;experiment host&#039;&#039; (localhost) only, but it &#039;&#039;&#039;IS required&#039;&#039;&#039; for access from a &#039;&#039;&#039;REMOTE&#039;&#039;&#039; frontend.&lt;br /&gt;
Start [[mserver]] on MIDAS host (default port 1175) or use the &amp;quot;-p&amp;quot; option for a different port.&lt;br /&gt;
The port must match the port defined for environment variable MIDAS_SERVER_HOST in {{File|name=.cshrc}} (or {{File|name=.bashrc}}) [[#Modify .cshrc (.bashrc) for Remote host|above]].&lt;br /&gt;
  &amp;lt;small&amp;gt;[mhostpc] mserver -D&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The environment variables on the REMOTE host should be:&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;&lt;br /&gt;
    [rlxhost] printenv | grep MIDAS&lt;br /&gt;
    MIDASSYS=/home/e777/packages/midas&lt;br /&gt;
    MIDAS_EXPT_NAME=e777&lt;br /&gt;
    MIDAS_SERVER_HOST=mhostpc.triumf.ca:1175&amp;lt;/span&amp;gt;&lt;br /&gt;
(a different port may be used - see above)&lt;br /&gt;
&lt;br /&gt;
=== Check access to ODB from Remote host ===&lt;br /&gt;
Run {{Utility|name=odbedit}} on the remote host to check access to ODB. &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] odbedit&lt;br /&gt;
 [mhostpc.triumf.ca:1175:e777:Stopped]/&amp;gt;ls &amp;lt;/span&amp;gt;&lt;br /&gt;
If it does not work correctly, check that &lt;br /&gt;
* MIDAS_SERVER_HOST is defined on REMOTE host with same port as [[mserver]]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:darkcyan;font-style:italic&amp;quot;&amp;gt;mserver&amp;lt;/span&amp;gt; is running on MIDAS host with the correct port&lt;br /&gt;
* MIDAS_SERVER_HOST is NOT defined on MIDAS host&lt;br /&gt;
* remote access permission to REMOTE host has been granted as described above.&lt;br /&gt;
&lt;br /&gt;
=== Build the analyzer on Experiment Host ===&lt;br /&gt;
The analyzer will be built and run on the MIDAS &#039;&#039;experiment host&#039;&#039; machine.&lt;br /&gt;
Select an example from $MIDASSYS/examples/ (see [[#Frontend and Analyzer (localhost)]]) and copy it to $HOME/online on the MIDAS host machine. Since we are assuming a 64-bit MIDAS host and a 32-bit remote host, edit the example Makefile so only the analyzer will be built. &lt;br /&gt;
&lt;br /&gt;
=== Build the frontend (32bit) for Remote host ===&lt;br /&gt;
The frontend runs on a 32-bit remote host in this example. It therefore must either&lt;br /&gt;
* be built 32-bit on the 64-bit MIDAS host with the &amp;quot;-m32&amp;quot; flag &lt;br /&gt;
* or built on the REMOTE host&lt;br /&gt;
and in either case the [[#Build 32-bit MIDAS libraries|32-bit MIDAS libraries]] used for linking. &lt;br /&gt;
&lt;br /&gt;
To avoid confusion, create a different subdirectory for the frontend, e.g.&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] mkdir $HOME/online/fe_32&amp;lt;/span&amp;gt;&lt;br /&gt;
Copy the Makefile and frontend code from the same example to this directory.&lt;br /&gt;
Modify the Makefile as needed, and only build the frontend.  &lt;br /&gt;
&lt;br /&gt;
Once built, start the frontend in an xterm on the REMOTE host. &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] $HOME/online/fe_32/frontend&amp;lt;/span&amp;gt;&lt;br /&gt;
Check that it connects successfully to the experiment and the Equipments appear on the [[Status Page]] as described under [[#Frontend and Analyzer (localhost)]].  The Equipment Status (Figure 2) should show that the Equipments are now running on the remote cpu, i.e. &amp;quot;SampleFrontend@rlxhost.triumf.ca&amp;quot; rather than &amp;quot;Sample Frontend@localhost&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Run the Analyzer on Experiment host ===&lt;br /&gt;
Start the analyzer in an xterm on the MIDAS &#039;&#039;experiment host&#039;&#039; &lt;br /&gt;
 &amp;lt;small&amp;gt;[johnfoo@mhostpc e777] $HOME/online/analyzer&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continue by starting a run and dumping the data as described under [[#Frontend and Analyzer (localhost)]].&lt;br /&gt;
&lt;br /&gt;
=== Create experiment startup script ===&lt;br /&gt;
It is useful to create a script that will automatically start all the required clients for the experiment. This is called a startup script (any name can be used). Create  {{Filepath|path=$HOME/online/bin/start_daq.sh}} on the &#039;&#039;experiment host&#039;&#039; as follows, (supply the [[mhttpd]] ports if default is not used) :&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 # start_daq.sh&lt;br /&gt;
 cd $HOME/online&lt;br /&gt;
 #&lt;br /&gt;
 switch (`hostname`)&lt;br /&gt;
   case $MIDAS_HOST*:    ## MIDAS_HOST is assigned in .cshrc (.bashrc)&lt;br /&gt;
      echo &amp;quot;Good, we are on $MIDAS_HOST&amp;quot;&lt;br /&gt;
      breaksw&lt;br /&gt;
   case $REMOTE_HOST*:   ## REMOTE_HOST is assigned in .cshrc (.bashrc)&lt;br /&gt;
      echo &amp;quot;startup script should be executed on $MIDAS_HOST&amp;quot;&lt;br /&gt;
 endsw&lt;br /&gt;
 #&lt;br /&gt;
 odbedit -c clean&lt;br /&gt;
 #   start mhttpd on default port (Mongoose https version)&lt;br /&gt;
 mhttpd  -D   # you can optionally restrict access to localhost and/or other specified hosts - see [[mhttpd]]&lt;br /&gt;
 #   start mserver on default port (use argument -p to use a different port) &lt;br /&gt;
 mserver -D  # start mserver on default port (1175) or a different port using -p option - see [[mserver]]&lt;br /&gt;
             # the port must match that of MIDAS_SERVER_HOST in .cshrc (.bashrc) - see above&lt;br /&gt;
             # access must be specifically allowed - see [[#Grant Remote host access permission||above]]&lt;br /&gt;
 xterm -e ./analyzer &amp;amp;&lt;br /&gt;
 ## start frontend on remote host&lt;br /&gt;
 #ssh $REMOTE_HOST $HOME/online/bin/start_frontend -O &amp;gt;&amp;amp; $HOME/online/bin/start_frontend.log  &amp;amp;&lt;br /&gt;
 mlogger -D&lt;br /&gt;
 #end file&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Note that command to start the frontend on the remote host is commented out. It can be uncommented once the start_frontend script is written and tested.&lt;br /&gt;
&lt;br /&gt;
Shut down any clients that are running already by running odbedit on the MIDAS &#039;&#039;experiment host&#039;&#039; and execute the new startup script   {{File|name=start_daq.sh}} (make it executable if desired)&lt;br /&gt;
 &amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] odbedit&lt;br /&gt;
   [local:e777:S]/&amp;gt;sh all&lt;br /&gt;
   [mhostpc] ./start_daq.sh &amp;lt;/small&amp;gt;&lt;br /&gt;
and check that {{Utility|name=odbedit}} still works on the &#039;&#039;REMOTE host&#039;&#039;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;&lt;br /&gt;
    [rlxhost] odbedit &lt;br /&gt;
    [mhostpc.triumf.ca:1175:e777:Stopped]/&amp;gt;ls &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may wish to modify the script to restart missing clients only.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create script to start frontend ===  &lt;br /&gt;
The startup file  {{File|name=start_daq.sh}}  invoked a script  {{File|name=start_frontend}} to start the remote frontend. This line was commented out (see [[#Create experiment startup script|above]]). Once the frontend is working, create a script to start the frontend (e.g. file {{Filepath|path=$HOME/online/bin/start_frontend}}).&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 #!/bin/tcsh&lt;br /&gt;
 # Script to start frontend running on $REMOTE_HOST&lt;br /&gt;
 #&lt;br /&gt;
 # This script runs on the REMOTE HOST&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;starting frontend for experiment $MIDAS_EXPT_NAME &amp;quot;&lt;br /&gt;
 xterm -geometry 150x50+800+0 -fg white -bg blue -title &amp;quot;Frontend&amp;quot; -e  &amp;quot;$HOME/online/fe_32/frontend&amp;quot; &amp;amp;&lt;br /&gt;
 echo &amp;quot;Frontend task has been started&amp;quot;&lt;br /&gt;
 exit&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Check that this script works by running it on the REMOTE host. If successful, &lt;br /&gt;
run the commented command in an xterm on the &#039;&#039;experiment host&#039;&#039;&lt;br /&gt;
    &amp;lt;small&amp;gt;[mhostpc] ssh $REMOTE_HOST $HOME/online/bin/start_frontend -O &amp;gt;&amp;amp; $HOME/online/bin/start_frontend.log  &amp;amp; &amp;lt;/small&amp;gt;&lt;br /&gt;
This command relies on password-less access set up with SSH keys (see [[#Experimental setup (Remote)]]).&lt;br /&gt;
If successful, uncomment line in {{File|name=start_daq.sh}}, and run the script to check that it can start the remote client(s) from the MIDAS &#039;&#039;experiment host&#039;&#039; (first shutting down all running clients) :&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
    [mhostpc] odbedit -c &amp;quot;sh all&amp;quot;&lt;br /&gt;
    [mhostpc] ./start_daq.sh &amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next [[#Customizing your experiment|customize your experiment]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Customizing your experiment ==&lt;br /&gt;
&lt;br /&gt;
Here are some of the more common options provided for users to customize their experiments according to their own preferences:&lt;br /&gt;
&lt;br /&gt;
; Write frontend(s) to read out and control your hardware&lt;br /&gt;
: Modify the example frontend and Makefile (from $MIDASSYS/examples/) you have already copied and built so it accesses your hardware. &lt;br /&gt;
&lt;br /&gt;
: The example Frontend.c is an example of [[Frontend user code]]. You can find documentation about the frontend structure under [[Frontend Application]], [[Frontend Operation]] and [[Frontend user code]]. You may need to set up some [[Event Notification (Hot-Link)|Hot-Links]] in the frontend. The MIDAS package includes device drivers for some of the more common hardware. See [[MIDAS Driver Library]] for more information.  &lt;br /&gt;
&lt;br /&gt;
; Modify analyzer(s) for your data &lt;br /&gt;
: Modify the example analyzer code as necessary to analyze the data from your frontends.&lt;br /&gt;
&lt;br /&gt;
; Slow Controls &lt;br /&gt;
: Control your slow-controls equipment with slow-control frontend(s) optionally using the [[#MIDAS Package Installation|MSCB]] system. &lt;br /&gt;
&lt;br /&gt;
; Data logger &lt;br /&gt;
: Set up the data logger [[mlogger]] to log data to a storage device. Many options are available - see [[Data Logger]], [[mlogger]] and [[/Logger ODB tree]] for instructions.&lt;br /&gt;
&lt;br /&gt;
; Allow programs to be restarted from the [[Programs Page]] &lt;br /&gt;
: See mhttpd [[Programs Page]] and [[/Programs ODB tree]]&lt;br /&gt;
&lt;br /&gt;
; Write scripts which run at start and end of run &lt;br /&gt;
: See [[/Programs ODB tree#Execute on start run]] and  [[/Programs ODB tree#Execute on stop run]]&lt;br /&gt;
&lt;br /&gt;
; Create a shutdown script &lt;br /&gt;
: Create a script similar to the startup script to shutdown the experiment&lt;br /&gt;
&lt;br /&gt;
; Lazy logger&lt;br /&gt;
: Set up the [[lazylogger]] for archiving data files for storage.&lt;br /&gt;
&lt;br /&gt;
; Create edit-on-start parameters &lt;br /&gt;
: See [[Edit-on-start Parameters]]&lt;br /&gt;
&lt;br /&gt;
; Set up the alarm system &lt;br /&gt;
: See [[Alarm System]] and [[Alarms Page]]&lt;br /&gt;
&lt;br /&gt;
; Set up history system &lt;br /&gt;
: See [[History System]] and [[History Page]]&lt;br /&gt;
&lt;br /&gt;
; Set up the Electronic logbook (Elog) &lt;br /&gt;
: See [[Elog]] for details&lt;br /&gt;
&lt;br /&gt;
; Set up the Sequencer &lt;br /&gt;
: The [[Sequencer Page#Sequencer]] can be used to run a sequence of runs, changing parameters as needed.  &lt;br /&gt;
&lt;br /&gt;
; Write a webserver Custom page &lt;br /&gt;
: To better control and monitor your experiment, you may want to write a [[Custom Page]].&lt;br /&gt;
&lt;br /&gt;
== Start MIDAS on boot ==&lt;br /&gt;
&lt;br /&gt;
To start MIDAS mhttpd, mlogger and elogd at boot time, add following cron entries:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[iris@iris00 ~]$ crontab -l&lt;br /&gt;
@reboot /home/iris/packages/midas/bin/mhttpd -D&lt;br /&gt;
@reboot /home/iris/packages/midas/bin/mlogger -D&lt;br /&gt;
@reboot /home/iris/packages/elog/elogd -c /home/iris/packages/elog/elogd.cfgiris -D&lt;br /&gt;
[iris@iris00 ~]$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Quickstart_Linux&amp;diff=3641</id>
		<title>Quickstart Linux</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Quickstart_Linux&amp;diff=3641"/>
		<updated>2026-09-29T16:15:38Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* MIDAS Package Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
This quickstart shows you how to install the MIDAS packages on a linux box and create a &#039;&#039;&#039;MIDAS experiment&#039;&#039;&#039;. &lt;br /&gt;
The linux box will be called the MIDAS &#039;&#039;&#039;&#039;&#039;experiment host&#039;&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
Log on to the &#039;&#039;[[#Introduction|Experiment Host]]&#039;&#039; and decide on a name for the MIDAS experiment (the &#039;&#039;experiment name&#039;&#039;).&lt;br /&gt;
In these instructions, the MIDAS packages and experiment will be installed under the username &amp;quot;johnfoo&amp;quot;. &lt;br /&gt;
The ODB and other shared memory buffers for the MIDAS experiment will reside on the &#039;&#039;experiment host&#039;&#039; (localhost).&lt;br /&gt;
MIDAS and the other required packages will be installed under directory  {{Filepath|path=$HOME/packages}}. The MIDAS &#039;&#039;experiment directory&#039;&#039; will be  {{Filepath|path=$HOME/online}} and the MIDAS &#039;&#039;experiment name&#039;&#039; will be &amp;quot;e777&amp;quot;. The name of the &#039;&#039;experiment host&#039;&#039; will be &amp;quot;mhostpc&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
;NOTE&lt;br /&gt;
: The user should substitute directory paths for the MIDAS packages and experiment directory as required, and names for &#039;&#039;experiment host&#039;&#039;, username, &#039;&#039;experiment name&#039;&#039; appropriate to his/her own setup.&lt;br /&gt;
&lt;br /&gt;
== Experimental setup ==&lt;br /&gt;
These instructions describe setting up an experiment that will run ONLY on the MIDAS &#039;&#039;experiment host&#039;&#039; computer (i.e. &#039;&#039;&#039;localhost only&#039;&#039;&#039;). In this case, the MIDAS &#039;&#039;experiment host&#039;&#039; has access to any hardware required, and all frontends, logger, analyzer etc. run on the one computer. &lt;br /&gt;
&lt;br /&gt;
Modifications to run an experiment with additional frontend(s) running &#039;&#039;&#039;remotely&#039;&#039;&#039; (i.e. on remote cpu(s)) will also be described.&lt;br /&gt;
Follow the instructions for setting up a localhost-only experiment until indicated. &lt;br /&gt;
 &lt;br /&gt;
In both cases, the main MIDAS applications (e.g. [[mlogger]], [[mhttpd]]) run on the MIDAS &#039;&#039;experiment host&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Environment Variables==&lt;br /&gt;
The following Environment variables should to be added to the  {{File|name=.cshrc}} or {{File|name=.bashrc}} file (depending on your shell) in the {{Filepath|path=$HOME}} directory on the &#039;&#039;experiment host&#039;&#039;,  so that they will be defined at login. &#039;&#039;&#039;Substitute appropriate values for your own setup&#039;&#039;&#039;. &lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! csh  !! bash !! comment&lt;br /&gt;
|-&lt;br /&gt;
| setenv MIDASSYS $HOME/packages/midas ||  export MIDASSYS=$HOME/packages/midas ||Base directory of the MIDAS package&lt;br /&gt;
|-&lt;br /&gt;
| setenv MIDAS_EXPTAB $HOME/online/exptab || export MIDAS_EXPTAB=$HOME/online/exptab  || MIDAS experiment table &lt;br /&gt;
|-&lt;br /&gt;
| setenv MIDAS_EXPT_NAME e777  || export MIDAS_EXPT_NAME=e777  || MIDAS experiment name&lt;br /&gt;
|-&lt;br /&gt;
| setenv PATH .:$MIDASSYS/bin:$PATH  || export PATH=$PATH:$MIDASSYS/bin || path&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Logout and login again, or source {{File|name=.cshrc}} (source {{File|name=.bashrc}}) for the changes to take effect.&lt;br /&gt;
;NOTE&lt;br /&gt;
: See [[MIDAS environment variables]] for a list of environment variables used by MIDAS.&lt;br /&gt;
&lt;br /&gt;
== ROOT Package Installation ==&lt;br /&gt;
MIDAS has optional integration with [https://root.cern.ch ROOT]. ROOT is not required for acquiring data or storing it in midas files, but is used by some of the analysis tools (including the example analyzer that will be built later in this Quickstart). It is also possible to write midas data directly to ROOT files if desired.&lt;br /&gt;
&lt;br /&gt;
If you require ROOT integration, follow the installation instructions on the [https://root.cern.ch ROOT website] and set the ROOTSYS environment variable.&lt;br /&gt;
&lt;br /&gt;
If you do not require ROOT integration, leave the ROOTSYS variable undefined.&lt;br /&gt;
&lt;br /&gt;
== Adding SSL support ==&lt;br /&gt;
&lt;br /&gt;
We recommend running mhttpd (the MIDAS web server) behind an industry-grade web proxy like apache httpd or nginx. httpd/nginx will then handle the SSL security. It is however also possible to build mhttpd with built-in SSL support. See [[Mhttpd|the mhttpd documentation]] for more details about web security.&lt;br /&gt;
&lt;br /&gt;
If you wish to enable SSL support in mhttpd itself:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
  [mhostpc] cd $MIDASSYS&lt;br /&gt;
  [mhostpc] make mbedtls&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MIDAS Package Installation ==&lt;br /&gt;
The MIDAS package will be installed on the &#039;&#039;experiment host&#039;&#039; in the directory given by MIDASSYS - see [[#Environment Variables]].&lt;br /&gt;
&lt;br /&gt;
Install the MIDAS and other package(s) from the MIDAS git repository in an xterm as follows:&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] mkdir $HOME/packages&lt;br /&gt;
   [mhostpc] cd $HOME/packages&lt;br /&gt;
   [mhostpc] git clone https://gitlab.triumf.ca/midas/midas.git --recurse-submodules&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you already cloned MIDAS and forgot the &amp;quot;--recurse-submodules&amp;quot;, you can do a &amp;quot;git submodule update --init --recursive&amp;quot; later. If you want to pull MIDAS later to update to the current version, you need either &amp;quot;git pull --recurse-submodules&amp;quot;. To tell git to always recurse, you can set a global flag via &amp;quot;git config submodule.recurse true&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The MIDAS Makefile will auto-detect whether MSCB, ROOT, MYSQL, SQLITE, ODBC etc. are available (or have been installed). If you need these features, make sure they are available before building the MIDAS package.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] cd $MIDASSYS&lt;br /&gt;
   [mhostpc] mkdir build&lt;br /&gt;
   [mhostpc] cd build&lt;br /&gt;
   [mhostpc] cmake ..                  ### configure build process (see note below about cmake/cmake3)&lt;br /&gt;
   [mhostpc] make install              ### build and install midas to bin/ and lib/ directories&lt;br /&gt;
   [mhostpc] cd ..&lt;br /&gt;
   [mhostpc] ls -l bin/odbedit         ### check that odbedit has been created (do not run it yet)&lt;br /&gt;
&amp;lt;/small&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
MIDAS requires cmake version 3.10 or later. On some systems, you have to call &amp;quot;cmake3 ..&amp;quot;, on others just &amp;quot;cmake ..&amp;quot;. Some systems might require you to install cmake first (see the [https://cmake.org/download/ cmake website; installation is very simple).&lt;br /&gt;
&lt;br /&gt;
In case of problems see &lt;br /&gt;
* [[Installation#Installing MIDAS|gitlab is down]] or &lt;br /&gt;
* [[Installation/Compilation problems#SSL certificate errors|SSL certificate errors]].&lt;br /&gt;
&lt;br /&gt;
==ROOTANA Package Installation==&lt;br /&gt;
&lt;br /&gt;
rootana is an optional framework for analyzing midas data in realtime and displaying plots (either by a graphical interface or via webpages). Most of the features are now available in manalyzer, which is included in the base midas install.&lt;br /&gt;
&lt;br /&gt;
If you require the legacy ROOTANA package, you can install it with:&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
    [mhostpc] cd $HOME/packages&lt;br /&gt;
    [mhostpc] git clone https://bitbucket.org/tmidas/rootana&lt;br /&gt;
    [mhostpc] cd rootana&lt;br /&gt;
    [mhostpc] make&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
add ROOTANASYS=$HOME/packages/rootana to the login file.&lt;br /&gt;
&lt;br /&gt;
Install the JSROOT package:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd $HOME/packages&lt;br /&gt;
git clone https://github.com/linev/jsroot.git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
add JSROOTSYS=$HOME/packages/jsroot to the login file.&lt;br /&gt;
&lt;br /&gt;
==ROODY Package Installation==&lt;br /&gt;
&lt;br /&gt;
ROODY is a legacy package for displaying live ROOT histograms. It is generally not used by new experiments.&lt;br /&gt;
&lt;br /&gt;
If ROODY is needed,&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
    [mhostpc] cd $HOME/packages&lt;br /&gt;
    [mhostpc] git clone https://bitbucket.org/tmidas/roody&lt;br /&gt;
    [mhostpc] cd roody&lt;br /&gt;
    [mhostpc] make&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Create the Experiment file exptab ==&lt;br /&gt;
In this example, the experimental directory is {{Filepath|path=$HOME/online}}. Create this directory on the &#039;&#039;experiment host&#039;&#039; (localhost):&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] mkdir $HOME/online&lt;br /&gt;
   [mhostpc] cd $HOME/online&amp;lt;/small&amp;gt;&lt;br /&gt;
Then create the [[exptab]] file {{Filepath|path=$HOME/online/exptab}} containing the three parameters:&lt;br /&gt;
# the experiment name &lt;br /&gt;
# location of MIDAS shared memory buffers&lt;br /&gt;
# username&lt;br /&gt;
as follows (using parameters for your own experiment):&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] cat &amp;gt; exptab&lt;br /&gt;
    e777 /home/johnfoo/online johnfoo&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The path of the  {{File|name=exptab}} file is given by MIDAS_EXPTAB - see [[#Environment Variables]].&lt;br /&gt;
&lt;br /&gt;
== Create shared memory files  ==&lt;br /&gt;
At this point you should be able to run [[odbedit]] on the &#039;&#039;experiment host&#039;&#039; (localhost). The first time  {{Utility|name=odbedit}} is run, it will create the required  {{File|name=.*.SHM}} files  in the MIDAS experiment directory  {{Filepath|path=$HOME/online}}. These are the saved files for the MIDAS shared memory.&lt;br /&gt;
&lt;br /&gt;
The default directory  {{Filepath|path=$HOME/online}} will contain the MIDAS messages file ({{File|name=midas.log}}) and&lt;br /&gt;
any data files you may create. If you want an alternative location for the data files see [[#Customizing your experiment]].&lt;br /&gt;
  &lt;br /&gt;
Run {{Utility|name=odbedit}}, and type {{Odbedit cmd|cmd=ls}} to list the default directories. &lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] odbedit&lt;br /&gt;
 [local:e777:S]/&amp;gt;ls&lt;br /&gt;
 Experiment&lt;br /&gt;
 System&lt;br /&gt;
 Programs&lt;br /&gt;
 Logger&lt;br /&gt;
 Runinfo&lt;br /&gt;
 Alarms&amp;lt;/small&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
== Run the MIDAS Web Server ==&lt;br /&gt;
&lt;br /&gt;
=== Using apache ===&lt;br /&gt;
&lt;br /&gt;
Recommended for production systems with maximum security is to run mhttpd behind an industry-standard SSL/https proxy with password protection. We document instructions for apache here, but you could nginx instead.&lt;br /&gt;
&lt;br /&gt;
To do this using apache httpd on CentOS-7, do this:&lt;br /&gt;
* configure apache httpd per instructions for [https://daq00.triumf.ca/DaqWiki/index.php/Ubuntu#Install_apache_httpd_proxy_for_midas_and_elog Ubuntu] or [https://daq00.triumf.ca/DaqWiki/index.php/SLinstall#Configure_HTTPS_server_.28CentOS7.29 CentOS 7]&lt;br /&gt;
* run mhttpd&lt;br /&gt;
* use web browser to connect to https://mhostpc/&lt;br /&gt;
* enter the user name and password configured in apache httpd&lt;br /&gt;
* the midas status page should open&lt;br /&gt;
&lt;br /&gt;
=== Standalone (less secure) ===&lt;br /&gt;
&lt;br /&gt;
For simplified installation, one can use standalone mhttpd with built-in https and password protection. This configuration&lt;br /&gt;
is only as secure as the underlying mongoose and OpenSSL web server and encryption packages. Use the odbedit tool to edit settings in the [[Webserver_ODB_tree|Webserver ODB tree]]:&lt;br /&gt;
&lt;br /&gt;
* Set &amp;quot;Enable https port&amp;quot; to &amp;quot;y&amp;quot;&lt;br /&gt;
* Set &amp;quot;https port passwords&amp;quot; to &amp;quot;y&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Many current operating systems implement a built-in firewall which will block outside access to mhttpd. See instructions for [https://daq00.triumf.ca/DaqWiki/index.php/SLinstall#Enable_firewall_for_MIDAS_.28CentOS7.29 CentOS 7].&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;
&lt;br /&gt;
You will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:13880: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:13881:mongoose,ERROR] please create password file: touch /home/johnfoo/online/htpasswd.txt&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:13818:mongoose,ERROR] mongoose web server password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot; has no passwords for realm &amp;quot;exptname&amp;quot;&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:13819:mongoose,ERROR] please add passwords by running: htdigest /home/johnfoo/online/htpasswd.txt exptname midas&lt;br /&gt;
  mongoose_init: Error: Cannot initialize authorization object!&lt;br /&gt;
  Error: Could not start the mongoose web server, see messages and midas.log, bye!&lt;br /&gt;
&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. (htdigest is part of the httpd-tools package)&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;
&lt;br /&gt;
Run {{Utility|name=mhttpd}} again.&lt;br /&gt;
&lt;br /&gt;
If you get error messages like &amp;lt;small&amp;gt;&amp;lt;code&amp;gt;https port &amp;quot;[::]:8443&amp;quot; requested, but mhttpd compiled without MG_ENABLE_SSL&amp;lt;/code&amp;gt;&amp;lt;/small&amp;gt; then you need to re-compile MIDAS after [[Mhttpd#Build_mhttpd_with_SSL_support|adding SSL support]].&lt;br /&gt;
&lt;br /&gt;
Otherwise, you will get the following messages: &lt;br /&gt;
 &amp;lt;small&amp;gt;&lt;br /&gt;
  HTTP Digest authentication with realm &amp;quot;exptname&amp;quot; and password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot;&lt;br /&gt;
  Hostlist off, connections from anywhere will be accepted&lt;br /&gt;
  Listening on &amp;quot;http://localhost:8080&amp;quot;, passwords OFF, hostlist OFF&lt;br /&gt;
  Listening on &amp;quot;http://[::1]:8080&amp;quot;, passwords OFF, hostlist OFF&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:15739:mongoose_listen,ERROR] cannot find SSL certificate file &amp;quot;/home/johnfoo/online/ssl_cert.pem&amp;quot;&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:15740:mongoose_listen,ERROR] please create SSL certificate file using openssl: cd $MIDASSYS; openssl req -new -nodes -newkey rsa:2048 -sha256 -out ssl_cert.csr -keyout ssl_cert.key -subj &amp;quot;/C=/ST=/L=/O=midas/OU=mhttpd/CN=localhost&amp;quot;; 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;
  [mhttpd,ERROR] [mhttpd.cxx:15741:mongoose_listen,ERROR] or using certbot (recommened): setup certbot per Let&#039;s Encrypt instructions, certificates are typically saved in /etc/letsencrypt/live/$HOSTNAME/, copy fullchain.pem and privkey.pem to $MIDASSYS; cd $MIDASSYS; cat fullchain.pem privkey.pem &amp;gt; ssl_cert.pem&lt;br /&gt;
  [mhttpd,ERROR] [mhttpd.cxx:15918:mongoose_init,ERROR] Failed to listen on a TCP port enabled in ODB /WebServer&lt;br /&gt;
  Error: Could not start the mongoose web server, see messages and midas.log, bye!&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a self-signed certificate suitable for initial testing by executing the commands printed by mhttpd.&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/https proxy (apache httpd).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now restart  {{Utility|name=mhttpd}}&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mhttpd&lt;br /&gt;
 HTTP Digest authentication with realm &amp;quot;test_pol&amp;quot; and password file &amp;quot;/home/johnfoo/online/htpasswd.txt&amp;quot;&lt;br /&gt;
 Hostlist off, connections from anywhere will be accepted&lt;br /&gt;
 Listening on &amp;quot;http://localhost:8080&amp;quot;, passwords OFF, hostlist OFF&lt;br /&gt;
 Listening on &amp;quot;http://[::1]:8080&amp;quot;, passwords OFF, hostlist OFF&lt;br /&gt;
 Mongoose web server will use https certificate file &amp;quot;./ssl_cert.pem&amp;quot;&lt;br /&gt;
 Listening on &amp;quot;https://[::]:8443&amp;quot;, passwords enabled, hostlist OFF&lt;br /&gt;
 Mongoose web server is using 1 threads&lt;br /&gt;
 Mongoose web server is using 2 threads&lt;br /&gt;
 Mongoose web server is using 3 threads&lt;br /&gt;
 Mongoose web server is using 4 threads&amp;lt;/small&amp;gt;&lt;br /&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;
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]]. To use some other ports, change the relevant values in the [[Webserver_ODB_tree|Webserver ODB tree]].&lt;br /&gt;
&lt;br /&gt;
== Run the MIDAS logger ==&lt;br /&gt;
Start the MIDAS logger [[mlogger]] on the &#039;&#039;experiment host&#039;&#039; (localhost) :&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] mlogger&amp;lt;/small&amp;gt; &lt;br /&gt;
This should start without error. It is usually run as a daemon, however in this case it is run in a terminal to check for errors. Starting the midas logger [[mlogger]] will automatically create more keys in the  {{Odbpath|path=/Logger}} ODB tree.&lt;br /&gt;
&lt;br /&gt;
From the MIDAS status page, go to the &amp;quot;Programs&amp;quot; page, then the &amp;quot;Logger&amp;quot; page and set ODB variables:&lt;br /&gt;
* Required -&amp;gt; set to &amp;quot;y&amp;quot;&lt;br /&gt;
* Start command -&amp;gt; set to &amp;quot;mlogger -D&amp;quot;&lt;br /&gt;
* Alarm Class -&amp;gt; set to &amp;quot;Alarm&amp;quot;&lt;br /&gt;
&lt;br /&gt;
To test this, go to the &amp;quot;Programs&amp;quot; page, press &amp;quot;stop logger&amp;quot;, then &amp;quot;start logger&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Start a run, wait 10 seconds, stop the run.&lt;br /&gt;
&lt;br /&gt;
From the MIDAS &amp;quot;Status&amp;quot; page, go to the &amp;quot;logging channels -&amp;gt; channel #0&amp;quot; and set ODB variables:&lt;br /&gt;
* Output -&amp;gt; &amp;quot;FILE&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Start a run, go to the &amp;quot;Status&amp;quot; page, observe that the output file is written with lz4 compression and has the &amp;quot;mid.lz4&amp;quot; extension.&lt;br /&gt;
&lt;br /&gt;
Stop the run.&lt;br /&gt;
&lt;br /&gt;
== Run test frontend ==&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;fetest&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the MIDAS &amp;quot;Status&amp;quot; page there will be 5 new equipment entries:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Equipment created by the fetest program&lt;br /&gt;
|-&lt;br /&gt;
! Equipment name !! Data it sends !! How often data is sent&lt;br /&gt;
|-&lt;br /&gt;
| test_random || Random data banks || 1Hz&lt;br /&gt;
|-&lt;br /&gt;
| test_slow || Example slow control data for testing the midas history plots || 1Hz, even when a run isn&#039;t in progress&lt;br /&gt;
|-&lt;br /&gt;
| test_rare || Data that look like a sine wave || 0.1Hz, even when a run isn&#039;t in progress&lt;br /&gt;
|-&lt;br /&gt;
| test_bulk || Large events || 1Hz&lt;br /&gt;
|-&lt;br /&gt;
| test_rpc || None. It shows an example of a &amp;quot;remote procedure call&amp;quot; (RPC) handler. Javascript/C++/Python code can connect to the program, and it will respond with the current time (in this toy example) || never&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note the event counters for test_slow and test_rare are already incrementing.&lt;br /&gt;
&lt;br /&gt;
Start a run.&lt;br /&gt;
&lt;br /&gt;
Observe that the event counters for test_bulk and test_random are also incrementing now, and that the output data file size is growing.&lt;br /&gt;
&lt;br /&gt;
Click on the &amp;quot;Event dump&amp;quot; page and then the &amp;quot;Run&amp;quot; button. You&#039;ll see the raw data that is being written to disk. (The data from most of the equipment is double-precision floating point numbers; the data from the &amp;quot;bulk&amp;quot; equipment is just a bunch of zeros).&lt;br /&gt;
&lt;br /&gt;
Return the status page and stop the run.&lt;br /&gt;
&lt;br /&gt;
== Create a history plot ==&lt;br /&gt;
&lt;br /&gt;
Go to the MIDAS &amp;quot;History&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Say &amp;quot;new&amp;quot;, panel name &amp;quot;test&amp;quot;. In the history editor select event &amp;quot;test_slow&amp;quot;, and click the &amp;quot;save&amp;quot; button (you can ignore the rest of the options for now). If the &amp;quot;test_slow&amp;quot; event isn&#039;t listed, make sure that the mlogger program is running, as described above.&lt;br /&gt;
&lt;br /&gt;
History plot &amp;quot;test&amp;quot; should open with a sine-wave plot. Data on the plot should update as long as &amp;quot;fetest&amp;quot; is running (there is no need to start a run).&lt;br /&gt;
&lt;br /&gt;
== Clients run on Localhost only ==&lt;br /&gt;
;NOTE: &lt;br /&gt;
* If creating a MIDAS experiment with a &#039;&#039;&#039;REMOTE&#039;&#039;&#039; frontend, &#039;&#039;&#039;continue by following the instructions&#039;&#039;&#039; [[#Running with one or more REMOTE frontends]].&lt;br /&gt;
* If all clients are running on the Experiment Host (i.e. &#039;&#039;&#039;localhost&#039;&#039;&#039;), continue with the following instructions:&lt;br /&gt;
&lt;br /&gt;
=== Frontend and Analyzer (localhost) ===&lt;br /&gt;
&lt;br /&gt;
THIS SECTION IS VERY OBSOLETE&lt;br /&gt;
&lt;br /&gt;
There are several examples of [[Frontend user code]] ({{File|name=frontend.c}}) in the MIDAS package available under {{Filepath|path=$MIDASSYS/examples/}}. Choose a suitable example from this directory that you can later modify for your own particular setup (e.g. for a slow control, choose the {{Filepath|path=../slowcont/}} example). &lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;frontend&#039;&#039;&#039; is a program that usually reads data from the hardware and sends it to a buffer to be logged and analyzed. You can find documentation about the frontend structure under [[Frontend Application]], [[Frontend Operation]] and [[Frontend user code]].&lt;br /&gt;
&lt;br /&gt;
The example chosen here is from  {{Filepath|path=$MIDASSYS/examples/experiment/}}. It does &#039;&#039;&#039;not need any hardware&#039;&#039;&#039; and produces simulated events.  &lt;br /&gt;
&lt;br /&gt;
On the MIDAS &#039;&#039;experiment host&#039;&#039; (localhost), copy the example to the experiment directory and build it.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
      [mhostpc] cd $HOME/online&lt;br /&gt;
      [mhostpc] cp $MIDASSYS/examples/experiment/* .&lt;br /&gt;
      [mhostpc] make&amp;lt;/small&amp;gt;&lt;br /&gt;
The analyzer will only build if ROOT has previously been installed.&lt;br /&gt;
At this point the frontend and the analyzer should be ready if no errors were generated during the build. Try the frontend and analyzer by starting them in xterms. &lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
      [mhostpc] frontend&lt;br /&gt;
      [mhostpc] analyzer&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Equipment ODB tree ===&lt;br /&gt;
Starting the frontend will automatically create the  {{Odbpath|path=/Equipment}} ODB tree and one or more equipments. In this case, the equipments &amp;quot;trigger&amp;quot; and &amp;quot;scaler&amp;quot; have been defined by code in  {{File|name=frontend.c}} and created the first time frontend runs.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
     [mhostpc] odbedit&lt;br /&gt;
     [local:e777:S]/&amp;gt;ls /equipment&lt;br /&gt;
     Trigger                         &lt;br /&gt;
     Scaler  &amp;lt;/small&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
View the MIDAS main status web page (by pointing your browser to https://localhost:8443/ or appropriate port if not using the default).&lt;br /&gt;
Observe on the [[Status Page]] that the two Equipments (Trigger, Scaler) have appeared in the Equipment section (Figure 1) and are coloured green.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Click thumbnail to enlarge&#039;&#039;&#039;&lt;br /&gt;
[[File:quickstart_status_page.png|thumb|left|Figure 1: web server status page showing example frontend equipments]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;clear: both&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;  &amp;lt;!-- clear wraparound after thumbnail --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rather than using odbedit,  you can view the contents of these equipments by clicking on the ODB button, then on {{Odbpath|path=/Equipment}}, then {{Odbpath|path=Trigger}} or {{Odbpath|path=Scaler}}. See [[ODB Page]] for more information.&lt;br /&gt;
&lt;br /&gt;
=== Start a run ===&lt;br /&gt;
Start a run by pressing the Start button on the [[Status Page]].&lt;br /&gt;
The Equipment display on the Status Page will now show some event statistics (Figure 2)&lt;br /&gt;
&#039;&#039;&#039;Click thumbnail to enlarge&#039;&#039;&#039;&lt;br /&gt;
[[File:sample_frontend_status.png|thumb|left|Figure 2: Equipments shown on Status Page showing event statistics]]&lt;br /&gt;
&amp;lt;div style=&amp;quot;clear: both&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;  &amp;lt;!-- clear wraparound after thumbnail --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The frontend will show an event display that will update when a run is started, e.g.&lt;br /&gt;
&lt;br /&gt;
 Sample Frontend connected to &amp;lt;local&amp;gt;. Press &amp;quot;!&amp;quot; to exit      18:48:2546:08&lt;br /&gt;
 ==========================================================================&lt;br /&gt;
 Run status:   Running    Run number 2                                   |/   /&lt;br /&gt;
 ===========================================================================&lt;br /&gt;
 Equipment     Status     Events     Events/sec Rate[B/s]  ODB-&amp;gt;FE FE-&amp;gt;OD&lt;br /&gt;
 ---------------------------------------------------------------------------&lt;br /&gt;
 Trigger       OK         13948      99.0       5413.0     0          140         &lt;br /&gt;
 Scaler        OK         15         0.3         15.4      0          15    &lt;br /&gt;
&lt;br /&gt;
The [[Status Page]] will also show events being generated (click the refresh button if necessary). &lt;br /&gt;
&lt;br /&gt;
=== Event Dump ===&lt;br /&gt;
While a run is in progress, the midas application [[mdump]] will provide you an event dump of the collected data from the running frontend, e.g.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
  mhostpc&amp;gt; mdump -l 50&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:whitesmoke&amp;quot;&amp;gt;blank&amp;lt;/span&amp;gt;&lt;br /&gt;
 - MIDAS revision: Mon Nov 2 11:50:51 2015 -0800 - 3b66779 -- Enter &amp;lt;!&amp;gt; to Exit ------- Midas Dump ---&lt;br /&gt;
 ------------------------ Event# 1 ------------------------&lt;br /&gt;
 Evid:0001- Mask:0000- Serial:0- Time:0x567a0c5d- Dsize:40/0x28&lt;br /&gt;
 #banks:2 - Bank list:-ADC0TDC0-&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:whitesmoke&amp;quot;&amp;gt;blank&amp;lt;/span&amp;gt;&lt;br /&gt;
 Bank:ADC0 Length: 8(I*1)/2(I*4)/4(Type) Type:Unsigned Integer*2&lt;br /&gt;
   1-&amp;gt; 0x0167 0x03c6 0x0069 0x0073 &lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:whitesmoke&amp;quot;&amp;gt;blank&amp;lt;/span&amp;gt;&lt;br /&gt;
 Bank:TDC0 Length: 8(I*1)/2(I*4)/4(Type) Type:Unsigned Integer*2&lt;br /&gt;
   1-&amp;gt; 0x0051 0x00ff 0x004a 0x00ec &lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
For further data processing/analysis, either the midas analyzer or the rootana can used for data display as well. &lt;br /&gt;
&lt;br /&gt;
=== Create a startup script (localhost) ===&lt;br /&gt;
It is useful to create a script that will automatically start all the required clients for the experiment. This is called a startup script. Here, the startup script will be  {{File|name=start_daq.sh}} (any name can be used). Create  {{Filepath|path=$HOME/online/bin/start_daq.sh}} on the &#039;&#039;experiment host&#039;&#039; as follows (supply the [[mhttpd]] ports if default is not used):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;small&amp;gt;#!/bin/sh&lt;br /&gt;
 # start_daq.sh&lt;br /&gt;
 cd $HOME/online&lt;br /&gt;
 odbedit -c clean&lt;br /&gt;
 #   start mhttpd on default port. (Mongoose https version)&lt;br /&gt;
 mhttpd  -D  # you can optionally restrict access to localhost and other specified hosts - see [[mhttpd]]&lt;br /&gt;
 xterm -e ./frontend &amp;amp;&lt;br /&gt;
 xterm -e ./analyzer &amp;amp;&lt;br /&gt;
 mlogger -D&lt;br /&gt;
 #end file&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before running this script, you will need to shutdown any running clients:&lt;br /&gt;
 &amp;lt;small&amp;gt;mhostpc&amp;gt; odbedit -c &amp;quot;sh all&amp;quot;&amp;lt;/small&amp;gt;&lt;br /&gt;
or you can use the  {{Utility|name=mhttpd}} [[Programs Page]] to shut them down.&lt;br /&gt;
&lt;br /&gt;
The script will start them as daemons. &lt;br /&gt;
By running the startup script start_daq.sh, several MIDAS applications will be started in sequence:&lt;br /&gt;
# Cleanup previous MIDAS application (if any).&lt;br /&gt;
# Start the MIDAS web server [mhttpd]&lt;br /&gt;
# Start the frontend application in its own xterm (for debugging purpose).&lt;br /&gt;
# Start the analyzer application in its own xterm (for debugging purpose).&lt;br /&gt;
# Start the MIDAS Data logger [mlogger]&lt;br /&gt;
  &amp;lt;small&amp;gt;[mhostpc] sh ./start_daq&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may wish to modify the script to restart missing clients only. &lt;br /&gt;
&lt;br /&gt;
Next [[#Customizing your experiment|customize your experiment]].&lt;br /&gt;
&lt;br /&gt;
== Running with one or more REMOTE frontends ==&lt;br /&gt;
These instructions assume you have already followed the instructions to setup an experiment running on the MIDAS experiment host (localhost), i.e. you have setup the MIDAS Environment variables, downloaded MIDAS packages, setup the [[mhttpd]] password and have {{Utility|name=mhttpd}} running successfully.&lt;br /&gt;
&lt;br /&gt;
In the case of &#039;&#039;&#039;remote&#039;&#039;&#039; frontend(s), the remote cpu(s) typically have access to some or all of the hardware. They might be VMIC cpus running in VME crates for example, connected to the MIDAS Host via Ethernet.  They read data from the hardware and send it back to the MIDAS &#039;&#039;experiment host&#039;&#039; to be logged and analyzed.&lt;br /&gt;
&lt;br /&gt;
=== Experimental setup (Remote) ===&lt;br /&gt;
These instructions assume that the MIDAS &#039;&#039;experiment host&#039;&#039; computer is 64-bit (if not see [[#Build 32-bit MIDAS libraries|note below]]), and there is one &#039;&#039;remote host&#039;&#039;, a 32-bit machine named &amp;quot;rlxhost&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;remote host&#039;&#039; mounts the {{Filepath|path=/home}} disk of the &#039;&#039;experiment host&#039;&#039;, so that it &#039;&#039;&#039;has access to the MIDAS packages&#039;&#039;&#039;, the {{Filepath|path=$HOME/online}} directory and shares the .cshrc (or .bashrc) script. It is convenient to set up ssh keys (use ssh-keygen) so that the &#039;&#039;remote host&#039;&#039; can be accessed without supplying the password from the &#039;&#039;experiment host&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If your setup is different, you will have to make changes as appropriate.  &lt;br /&gt;
&lt;br /&gt;
=== Build 32-bit MIDAS libraries ===&lt;br /&gt;
NOTE&lt;br /&gt;
&amp;lt;p style=&amp;quot;margin-left:40px;margin-right:40px;&amp;quot;&amp;gt;&lt;br /&gt;
If the MIDAS &#039;&#039;experiment host&#039;&#039; computer is 32-bit (i.e. the same as the &#039;&#039;remote host&#039;&#039;), which is a simpler setup, you will have built the 32-bit MIDAS libraries already, and can skip the rest of this section. Note however, that in the .cshrc file in the  [[#Modify .cshrc (.bashrc) for Remote host|following section]] you will not need the lines starting &amp;quot;# select 64-bit or 32-bit MIDAS and ROOT&amp;quot;.  The PATH should contain &amp;lt;span style=&amp;quot;color:#214200; font-weight:normal; font-style:italic&amp;quot;&amp;gt;$MIDASSYS/bin&amp;lt;/span&amp;gt; on both experiment host and remote host. This will point to the 32-bit MIDAS libraries. &lt;br /&gt;
------------------------------&lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Assuming the MIDAS host computer is 64-bit, you will have already built the 64-bit MIDAS libraries.&lt;br /&gt;
In this case, if the remote frontend is 32-bit, you will need to build the 32-bit MIDAS libraries on the 64-bit machine, i.e.&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
    [mhostpc] cd /home/packages/midas&lt;br /&gt;
    [mhostpc] make linux32                ### build the 32-bit MIDAS libraries on 64-bit machine&lt;br /&gt;
    [mhostpc] ls -l linux-m32/bin/odbedit ### check that the 32-bit odbedit has been created &amp;lt;/small&amp;gt;&lt;br /&gt;
Do not run  {{Utility|name=odbedit}} yet on the &#039;&#039;remote host&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If the &amp;quot;make linux32&amp;quot; command fails, you may need to install 32bit support for your compiler (e.g. &amp;quot;apt install g++-multilib&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
=== Modify .cshrc (.bashrc) for Remote host ===&lt;br /&gt;
Add the following to the {{File|name=.cshrc}} (modified appropriately if using {{File|name=.bashrc}}).  When running with a REMOTE Host, the application [[mserver]] will be started (using a particular port) on the MIDAS &#039;&#039;experiment host&#039;&#039; machine only.  Note that the environment variable MIDAS_SERVER_HOST is defined on the remote machine(s) but NOT on the &#039;&#039;experiment host&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
If ROOT has been installed properly and the script &amp;lt;ROOT installation directory&amp;gt;/bin/thisroot.sh is called from .cshrc or .bashrc, the ROOTSYS environment variable should be defined and the ROOT bin directory should be in the PATH environment variable. Make sure that this is the case.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 # setenv MIDAS_HOST mhostpc   # substitute your experiment host name&lt;br /&gt;
 # setenv REMOTE_HOST rlxhost  # substitute your remote host name&lt;br /&gt;
 # setup the MIDAS mserver host&lt;br /&gt;
 #&lt;br /&gt;
 switch (`hostname`)&lt;br /&gt;
 case $MIDAS_HOST*:                &lt;br /&gt;
   unsetenv MIDAS_SERVER_HOST     ## MIDAS_SERVER_HOST not defined&lt;br /&gt;
   breaksw&lt;br /&gt;
 default:&lt;br /&gt;
 setenv MIDAS_SERVER_HOST $MIDAS_HOST.triumf.ca:1175  ## for remote host, define MIDAS_SERVER_HOST, use your domain here&lt;br /&gt;
                                                      ## as hostname + domain name + default mserver port&lt;br /&gt;
                                                      ## port must match that of [[mserver]] used in start_daq.sh &lt;br /&gt;
 endsw&lt;br /&gt;
 #&lt;br /&gt;
 # select 64-bit or 32-bit MIDAS&lt;br /&gt;
 #&lt;br /&gt;
 switch (`uname -i`)&lt;br /&gt;
 case i386:&lt;br /&gt;
   setenv PATH .:$MIDASSYS/linux-m32/bin:$PATH&lt;br /&gt;
   breaksw&lt;br /&gt;
 default:&lt;br /&gt;
   setenv PATH .:$MIDASSYS/linux/bin:$PATH&lt;br /&gt;
 endsw&lt;br /&gt;
 #&lt;br /&gt;
 setenv PATH .:$HOME/online/bin:$HOME/packages/roody/bin:$PATH&lt;br /&gt;
 #&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
After executing {{File|name=.cshrc}} (or {{File|name=.bashrc}}) or logging out, on the MIDAS host (mhostpc) make sure environment variable MIDAS_SERVER_HOST is NOT defined&lt;br /&gt;
 &amp;lt;small&amp;gt;[mhostpc] echo $MIDAS_SERVER_HOST&lt;br /&gt;
 [mhostpc] MIDAS_SERVER_HOST: Undefined variable.&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and on the  &#039;&#039;&#039;&#039;&#039;remote host&#039;&#039;&#039;&#039;&#039;, make sure MIDAS_SERVER_HOST IS defined: &lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] echo $MIDAS_SERVER_HOST&lt;br /&gt;
  [rlxhost] MIDAS_SERVER_HOST&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also on the &#039;&#039;remote host&#039;&#039;, make sure that the correct (32-bit)  {{Utility|name=odbedit}} will be used (do not run it yet!)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] which odbedit&lt;br /&gt;
 /home/johnfoo/packages/midas/linux-m32/bin/odbedit&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Grant Remote host access permission === &lt;br /&gt;
Give permission for the remote host(s) to access the experiment by following the instructions to [[Security#MIDAS programs on remote machines|allow MIDAS programs on remote machines]].  If the MIDAS web server [[mhttpd]] is running, use [[ODB Page]] to edit the ODB keys listed, otherwise use [[odbedit]] on the &#039;&#039;experiment host&#039;&#039; machine.&lt;br /&gt;
 &lt;br /&gt;
=== Start mserver on Experiment Host ===&lt;br /&gt;
The application [[mserver]] is not required when running an experiment on the &#039;&#039;experiment host&#039;&#039; (localhost) only, but it &#039;&#039;&#039;IS required&#039;&#039;&#039; for access from a &#039;&#039;&#039;REMOTE&#039;&#039;&#039; frontend.&lt;br /&gt;
Start [[mserver]] on MIDAS host (default port 1175) or use the &amp;quot;-p&amp;quot; option for a different port.&lt;br /&gt;
The port must match the port defined for environment variable MIDAS_SERVER_HOST in {{File|name=.cshrc}} (or {{File|name=.bashrc}}) [[#Modify .cshrc (.bashrc) for Remote host|above]].&lt;br /&gt;
  &amp;lt;small&amp;gt;[mhostpc] mserver -D&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The environment variables on the REMOTE host should be:&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;&lt;br /&gt;
    [rlxhost] printenv | grep MIDAS&lt;br /&gt;
    MIDASSYS=/home/e777/packages/midas&lt;br /&gt;
    MIDAS_EXPT_NAME=e777&lt;br /&gt;
    MIDAS_SERVER_HOST=mhostpc.triumf.ca:1175&amp;lt;/span&amp;gt;&lt;br /&gt;
(a different port may be used - see above)&lt;br /&gt;
&lt;br /&gt;
=== Check access to ODB from Remote host ===&lt;br /&gt;
Run {{Utility|name=odbedit}} on the remote host to check access to ODB. &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] odbedit&lt;br /&gt;
 [mhostpc.triumf.ca:1175:e777:Stopped]/&amp;gt;ls &amp;lt;/span&amp;gt;&lt;br /&gt;
If it does not work correctly, check that &lt;br /&gt;
* MIDAS_SERVER_HOST is defined on REMOTE host with same port as [[mserver]]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color:darkcyan;font-style:italic&amp;quot;&amp;gt;mserver&amp;lt;/span&amp;gt; is running on MIDAS host with the correct port&lt;br /&gt;
* MIDAS_SERVER_HOST is NOT defined on MIDAS host&lt;br /&gt;
* remote access permission to REMOTE host has been granted as described above.&lt;br /&gt;
&lt;br /&gt;
=== Build the analyzer on Experiment Host ===&lt;br /&gt;
The analyzer will be built and run on the MIDAS &#039;&#039;experiment host&#039;&#039; machine.&lt;br /&gt;
Select an example from $MIDASSYS/examples/ (see [[#Frontend and Analyzer (localhost)]]) and copy it to $HOME/online on the MIDAS host machine. Since we are assuming a 64-bit MIDAS host and a 32-bit remote host, edit the example Makefile so only the analyzer will be built. &lt;br /&gt;
&lt;br /&gt;
=== Build the frontend (32bit) for Remote host ===&lt;br /&gt;
The frontend runs on a 32-bit remote host in this example. It therefore must either&lt;br /&gt;
* be built 32-bit on the 64-bit MIDAS host with the &amp;quot;-m32&amp;quot; flag &lt;br /&gt;
* or built on the REMOTE host&lt;br /&gt;
and in either case the [[#Build 32-bit MIDAS libraries|32-bit MIDAS libraries]] used for linking. &lt;br /&gt;
&lt;br /&gt;
To avoid confusion, create a different subdirectory for the frontend, e.g.&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] mkdir $HOME/online/fe_32&amp;lt;/span&amp;gt;&lt;br /&gt;
Copy the Makefile and frontend code from the same example to this directory.&lt;br /&gt;
Modify the Makefile as needed, and only build the frontend.  &lt;br /&gt;
&lt;br /&gt;
Once built, start the frontend in an xterm on the REMOTE host. &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;[rlxhost] $HOME/online/fe_32/frontend&amp;lt;/span&amp;gt;&lt;br /&gt;
Check that it connects successfully to the experiment and the Equipments appear on the [[Status Page]] as described under [[#Frontend and Analyzer (localhost)]].  The Equipment Status (Figure 2) should show that the Equipments are now running on the remote cpu, i.e. &amp;quot;SampleFrontend@rlxhost.triumf.ca&amp;quot; rather than &amp;quot;Sample Frontend@localhost&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Run the Analyzer on Experiment host ===&lt;br /&gt;
Start the analyzer in an xterm on the MIDAS &#039;&#039;experiment host&#039;&#039; &lt;br /&gt;
 &amp;lt;small&amp;gt;[johnfoo@mhostpc e777] $HOME/online/analyzer&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continue by starting a run and dumping the data as described under [[#Frontend and Analyzer (localhost)]].&lt;br /&gt;
&lt;br /&gt;
=== Create experiment startup script ===&lt;br /&gt;
It is useful to create a script that will automatically start all the required clients for the experiment. This is called a startup script (any name can be used). Create  {{Filepath|path=$HOME/online/bin/start_daq.sh}} on the &#039;&#039;experiment host&#039;&#039; as follows, (supply the [[mhttpd]] ports if default is not used) :&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 # start_daq.sh&lt;br /&gt;
 cd $HOME/online&lt;br /&gt;
 #&lt;br /&gt;
 switch (`hostname`)&lt;br /&gt;
   case $MIDAS_HOST*:    ## MIDAS_HOST is assigned in .cshrc (.bashrc)&lt;br /&gt;
      echo &amp;quot;Good, we are on $MIDAS_HOST&amp;quot;&lt;br /&gt;
      breaksw&lt;br /&gt;
   case $REMOTE_HOST*:   ## REMOTE_HOST is assigned in .cshrc (.bashrc)&lt;br /&gt;
      echo &amp;quot;startup script should be executed on $MIDAS_HOST&amp;quot;&lt;br /&gt;
 endsw&lt;br /&gt;
 #&lt;br /&gt;
 odbedit -c clean&lt;br /&gt;
 #   start mhttpd on default port (Mongoose https version)&lt;br /&gt;
 mhttpd  -D   # you can optionally restrict access to localhost and/or other specified hosts - see [[mhttpd]]&lt;br /&gt;
 #   start mserver on default port (use argument -p to use a different port) &lt;br /&gt;
 mserver -D  # start mserver on default port (1175) or a different port using -p option - see [[mserver]]&lt;br /&gt;
             # the port must match that of MIDAS_SERVER_HOST in .cshrc (.bashrc) - see above&lt;br /&gt;
             # access must be specifically allowed - see [[#Grant Remote host access permission||above]]&lt;br /&gt;
 xterm -e ./analyzer &amp;amp;&lt;br /&gt;
 ## start frontend on remote host&lt;br /&gt;
 #ssh $REMOTE_HOST $HOME/online/bin/start_frontend -O &amp;gt;&amp;amp; $HOME/online/bin/start_frontend.log  &amp;amp;&lt;br /&gt;
 mlogger -D&lt;br /&gt;
 #end file&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Note that command to start the frontend on the remote host is commented out. It can be uncommented once the start_frontend script is written and tested.&lt;br /&gt;
&lt;br /&gt;
Shut down any clients that are running already by running odbedit on the MIDAS &#039;&#039;experiment host&#039;&#039; and execute the new startup script   {{File|name=start_daq.sh}} (make it executable if desired)&lt;br /&gt;
 &amp;lt;small&amp;gt;&lt;br /&gt;
   [mhostpc] odbedit&lt;br /&gt;
   [local:e777:S]/&amp;gt;sh all&lt;br /&gt;
   [mhostpc] ./start_daq.sh &amp;lt;/small&amp;gt;&lt;br /&gt;
and check that {{Utility|name=odbedit}} still works on the &#039;&#039;REMOTE host&#039;&#039;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:green; font-size:80%&amp;quot;&amp;gt;&lt;br /&gt;
    [rlxhost] odbedit &lt;br /&gt;
    [mhostpc.triumf.ca:1175:e777:Stopped]/&amp;gt;ls &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may wish to modify the script to restart missing clients only.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Create script to start frontend ===  &lt;br /&gt;
The startup file  {{File|name=start_daq.sh}}  invoked a script  {{File|name=start_frontend}} to start the remote frontend. This line was commented out (see [[#Create experiment startup script|above]]). Once the frontend is working, create a script to start the frontend (e.g. file {{Filepath|path=$HOME/online/bin/start_frontend}}).&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
 #!/bin/tcsh&lt;br /&gt;
 # Script to start frontend running on $REMOTE_HOST&lt;br /&gt;
 #&lt;br /&gt;
 # This script runs on the REMOTE HOST&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;starting frontend for experiment $MIDAS_EXPT_NAME &amp;quot;&lt;br /&gt;
 xterm -geometry 150x50+800+0 -fg white -bg blue -title &amp;quot;Frontend&amp;quot; -e  &amp;quot;$HOME/online/fe_32/frontend&amp;quot; &amp;amp;&lt;br /&gt;
 echo &amp;quot;Frontend task has been started&amp;quot;&lt;br /&gt;
 exit&lt;br /&gt;
&amp;lt;/small&amp;gt;&lt;br /&gt;
Check that this script works by running it on the REMOTE host. If successful, &lt;br /&gt;
run the commented command in an xterm on the &#039;&#039;experiment host&#039;&#039;&lt;br /&gt;
    &amp;lt;small&amp;gt;[mhostpc] ssh $REMOTE_HOST $HOME/online/bin/start_frontend -O &amp;gt;&amp;amp; $HOME/online/bin/start_frontend.log  &amp;amp; &amp;lt;/small&amp;gt;&lt;br /&gt;
This command relies on password-less access set up with SSH keys (see [[#Experimental setup (Remote)]]).&lt;br /&gt;
If successful, uncomment line in {{File|name=start_daq.sh}}, and run the script to check that it can start the remote client(s) from the MIDAS &#039;&#039;experiment host&#039;&#039; (first shutting down all running clients) :&lt;br /&gt;
&amp;lt;small&amp;gt;&lt;br /&gt;
    [mhostpc] odbedit -c &amp;quot;sh all&amp;quot;&lt;br /&gt;
    [mhostpc] ./start_daq.sh &amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next [[#Customizing your experiment|customize your experiment]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Customizing your experiment ==&lt;br /&gt;
&lt;br /&gt;
Here are some of the more common options provided for users to customize their experiments according to their own preferences:&lt;br /&gt;
&lt;br /&gt;
; Write frontend(s) to read out and control your hardware&lt;br /&gt;
: Modify the example frontend and Makefile (from $MIDASSYS/examples/) you have already copied and built so it accesses your hardware. &lt;br /&gt;
&lt;br /&gt;
: The example Frontend.c is an example of [[Frontend user code]]. You can find documentation about the frontend structure under [[Frontend Application]], [[Frontend Operation]] and [[Frontend user code]]. You may need to set up some [[Event Notification (Hot-Link)|Hot-Links]] in the frontend. The MIDAS package includes device drivers for some of the more common hardware. See [[MIDAS Driver Library]] for more information.  &lt;br /&gt;
&lt;br /&gt;
; Modify analyzer(s) for your data &lt;br /&gt;
: Modify the example analyzer code as necessary to analyze the data from your frontends.&lt;br /&gt;
&lt;br /&gt;
; Slow Controls &lt;br /&gt;
: Control your slow-controls equipment with slow-control frontend(s) optionally using the [[#MIDAS Package Installation|MSCB]] system. &lt;br /&gt;
&lt;br /&gt;
; Data logger &lt;br /&gt;
: Set up the data logger [[mlogger]] to log data to a storage device. Many options are available - see [[Data Logger]], [[mlogger]] and [[/Logger ODB tree]] for instructions.&lt;br /&gt;
&lt;br /&gt;
; Allow programs to be restarted from the [[Programs Page]] &lt;br /&gt;
: See mhttpd [[Programs Page]] and [[/Programs ODB tree]]&lt;br /&gt;
&lt;br /&gt;
; Write scripts which run at start and end of run &lt;br /&gt;
: See [[/Programs ODB tree#Execute on start run]] and  [[/Programs ODB tree#Execute on stop run]]&lt;br /&gt;
&lt;br /&gt;
; Create a shutdown script &lt;br /&gt;
: Create a script similar to the startup script to shutdown the experiment&lt;br /&gt;
&lt;br /&gt;
; Lazy logger&lt;br /&gt;
: Set up the [[lazylogger]] for archiving data files for storage.&lt;br /&gt;
&lt;br /&gt;
; Create edit-on-start parameters &lt;br /&gt;
: See [[Edit-on-start Parameters]]&lt;br /&gt;
&lt;br /&gt;
; Set up the alarm system &lt;br /&gt;
: See [[Alarm System]] and [[Alarms Page]]&lt;br /&gt;
&lt;br /&gt;
; Set up history system &lt;br /&gt;
: See [[History System]] and [[History Page]]&lt;br /&gt;
&lt;br /&gt;
; Set up the Electronic logbook (Elog) &lt;br /&gt;
: See [[Elog]] for details&lt;br /&gt;
&lt;br /&gt;
; Set up the Sequencer &lt;br /&gt;
: The [[Sequencer Page#Sequencer]] can be used to run a sequence of runs, changing parameters as needed.  &lt;br /&gt;
&lt;br /&gt;
; Write a webserver Custom page &lt;br /&gt;
: To better control and monitor your experiment, you may want to write a [[Custom Page]].&lt;br /&gt;
&lt;br /&gt;
== Start MIDAS on boot ==&lt;br /&gt;
&lt;br /&gt;
To start MIDAS mhttpd, mlogger and elogd at boot time, add following cron entries:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[iris@iris00 ~]$ crontab -l&lt;br /&gt;
@reboot /home/iris/packages/midas/bin/mhttpd -D&lt;br /&gt;
@reboot /home/iris/packages/midas/bin/mlogger -D&lt;br /&gt;
@reboot /home/iris/packages/elog/elogd -c /home/iris/packages/elog/elogd.cfgiris -D&lt;br /&gt;
[iris@iris00 ~]$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Python&amp;diff=3640</id>
		<title>Python</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Python&amp;diff=3640"/>
		<updated>2026-09-29T16:14:53Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Since December 2019, midas has shipped with python wrappers allowing midas clients to be written in python.&lt;br /&gt;
&lt;br /&gt;
The main features are:&lt;br /&gt;
* A file reader, which works with python 2.7 and python 3.x&lt;br /&gt;
* A client library and frontend framework which work with python 3.x only&lt;br /&gt;
&lt;br /&gt;
To use the python libraries, you must have installed midas, and compiled midas using cmake. The python code is found at &amp;lt;code&amp;gt;$MIDASSYS/python&amp;lt;/code&amp;gt;. You can view [https://gitlab.triumf.ca/midas/midas/-/tree/develop/python/examples example scripts and frontends on GitLab].&lt;br /&gt;
&lt;br /&gt;
== Midas file reader ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;midas/file_reader.py&amp;lt;/code&amp;gt; is a pure-python tool that lets you read midas files.&lt;br /&gt;
It presents a very pythonic interface, allowing you to do things like &lt;br /&gt;
&lt;br /&gt;
 import midas.file_reader&lt;br /&gt;
 &lt;br /&gt;
 my_file = midas.file_reader.MidasFile(&amp;quot;/path/to/file.mid.lz4&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 for event in my_file:&lt;br /&gt;
   event.dump()&lt;br /&gt;
&lt;br /&gt;
To access information in the ODB dump, you can do something like&lt;br /&gt;
&lt;br /&gt;
 import midas.file_reader&lt;br /&gt;
 &lt;br /&gt;
 my_file = midas.file_reader.MidasFile(&amp;quot;/path/to/file.mid.lz4&amp;quot;)&lt;br /&gt;
 odb = my_file.get_bor_odb_dump().data&lt;br /&gt;
 &lt;br /&gt;
 run_number = odb[&amp;quot;Runinfo&amp;quot;][&amp;quot;Run number&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
For more details, see the documentation in &amp;lt;code&amp;gt;$MIDASSYS/python/midas/file_reader.py&amp;lt;/code&amp;gt; and example code in &amp;lt;code&amp;gt;$MIDASSYS/python/examples/file_reader.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* It works with python 2.7 and python 3.&lt;br /&gt;
* It does not require the rest of midas to be compiled.&lt;br /&gt;
&lt;br /&gt;
== Client and frontend libraries ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;midas/client.py&amp;lt;/code&amp;gt; provides pythonic access to a midas experiment, by wrapping midas&#039; C library. It provides nice ODB access through functions like &amp;lt;code&amp;gt;odb_set&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;odb_get&amp;lt;/code&amp;gt;, and can also handle event buffers, callback functions and more.&lt;br /&gt;
* &amp;lt;code&amp;gt;midas/frontend.py&amp;lt;/code&amp;gt; builds upon the client and provides a framework for writing midas frontends in python. It supports periodic and polled equipment, and can be controlled just like a C frontend.&lt;br /&gt;
&lt;br /&gt;
Many users write scripts in python or bash that call the &amp;lt;code&amp;gt;odbedit&amp;lt;/code&amp;gt; command-line tool or the mhttpd web server. We hope that the pythonic midas client tools will simplify and robustify such scripts. The python frontend framework may prove particularly beneficial for controlling devices that natively talk in JSON or other text-based protocols that are&lt;br /&gt;
tedious to deal with in C. It may also reduce the development time required to write frontends that do not have strict performance requirements.&lt;br /&gt;
&lt;br /&gt;
* They work with python 3 only.&lt;br /&gt;
* They require the rest of midas to be compiled, as they use the midas C library. For the correct libraries to be built, you must compile using CMake&lt;br /&gt;
* They are designed for ease of use, rather than optimal performance. If performance is critical for your application, you should write your code in C.&lt;br /&gt;
&lt;br /&gt;
The python &amp;lt;code&amp;gt;midas.client&amp;lt;/code&amp;gt; library provides support for:&lt;br /&gt;
* ODB access - creating/deleting/renaming keys, getting/setting/watching values, creating links&lt;br /&gt;
* run transitions - starting/stopping/pausing/resuming runs, and registering callback functions for each transition&lt;br /&gt;
* event buffers - connecting, sending events, receiving events&lt;br /&gt;
* remote procedure calls - connecting and talking to other midas clients&lt;br /&gt;
* alarms - creating and triggering alarms&lt;br /&gt;
* messages - sending and getting recent messages&lt;br /&gt;
* history system - reading data (since July 2023)&lt;br /&gt;
&lt;br /&gt;
== Documentation ==&lt;br /&gt;
&lt;br /&gt;
Documentation of the tools is written as docstrings in the source code (in &amp;lt;code&amp;gt;$MIDASSYS/python/midas&amp;lt;/code&amp;gt;). We do not currently have a web version of the documentation.&lt;br /&gt;
&lt;br /&gt;
The documentation assumes a reasonable familiarity with core midas concepts. See the rest of this wiki if you&#039;re unfamiliar with a term or concept in the python documentation.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
We highly recommend using [https://pypi.org/project/pip/ pip] and/or [https://virtualenv.pypa.io/en/latest/ virtualenv] to manage your python packages, but you can also just edit your paths if desired.&lt;br /&gt;
&lt;br /&gt;
To install this package with pip:&lt;br /&gt;
&lt;br /&gt;
 pip install -e $MIDASSYS/python --user&lt;br /&gt;
 # The -e flag makes this an &amp;quot;editable&amp;quot; install. If you upgrade midas in future,&lt;br /&gt;
 # python will automatically see the new code without you having to re-install.&lt;br /&gt;
 # The --user flag may or may not be needed, depending on your pip setup.&lt;br /&gt;
&lt;br /&gt;
The python code has some &amp;lt;b&amp;gt;optional dependencies&amp;lt;/b&amp;gt; that enable extra functionality:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;numpy&amp;lt;/code&amp;gt; can be used to improve performance in midas python frontends that are running at high data rates&lt;br /&gt;
* &amp;lt;code&amp;gt;lz4&amp;lt;/code&amp;gt; allows the midas file reader to parse .mid.lz4 files (.mid and .mid.gz files do not need any extra pacakges)&lt;br /&gt;
* &amp;lt;code&amp;gt;pyflakes&amp;lt;/code&amp;gt; allows the PySequencer to validate the syntax of your script before it gets executed, catching many errors before they are encountered&lt;br /&gt;
&lt;br /&gt;
As of September 2026, the optional dependencies will be installed automatically when you &amp;quot;pip install&amp;quot; the midas package.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to use pip, a hacky way to &amp;quot;install&amp;quot; is by editing environment variables. This will not install any of the optional dependencies.&lt;br /&gt;
&lt;br /&gt;
 export PYTHONPATH=$PYTHONPATH:$MIDASSYS/python&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
You can now use &amp;lt;code&amp;gt;import midas&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;import midas.client&amp;lt;/code&amp;gt; etc in your python scripts.&lt;br /&gt;
&lt;br /&gt;
[https://gitlab.triumf.ca/midas/midas/-/tree/develop/python/examples $MIDASSYS/python/examples] contains several examples of complete clients and frontends written in python.&lt;br /&gt;
&lt;br /&gt;
=== midas.client ODB access ===&lt;br /&gt;
&lt;br /&gt;
Here we show a very simple python script for interacting with the ODB. Note that we do not have any error-checking. If any call to the midas library fails, an exception will be raised.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;import midas.client&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
A simple example program that connects to a midas experiment,&lt;br /&gt;
reads an ODB value, then sets an ODB value.&lt;br /&gt;
&lt;br /&gt;
Expected output is:&lt;br /&gt;
&lt;br /&gt;
```&lt;br /&gt;
The experiment is currently stopped&lt;br /&gt;
The new value of /pyexample/eg_float is 5.670000&lt;br /&gt;
```&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    client = midas.client.MidasClient(&amp;quot;pytest&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    # Read a value from the ODB. The return value is a normal python&lt;br /&gt;
    # type (an int in this case, but could also be a float, string, bool,&lt;br /&gt;
    # list or dict).&lt;br /&gt;
    state = client.odb_get(&amp;quot;/Runinfo/State&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    if state == midas.STATE_RUNNING:&lt;br /&gt;
        print(&amp;quot;The experiment is currently running&amp;quot;)&lt;br /&gt;
    elif state == midas.STATE_PAUSED:&lt;br /&gt;
        print(&amp;quot;The experiment is currently paused&amp;quot;)&lt;br /&gt;
    elif state == midas.STATE_STOPPED:&lt;br /&gt;
        print(&amp;quot;The experiment is currently stopped&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        print(&amp;quot;The experiment is in an unexpected run state&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # Update or create a directory in the ODB by passing a dict to `odb_set`&lt;br /&gt;
    client.odb_set(&amp;quot;/pyexample&amp;quot;, {&amp;quot;an_int&amp;quot;: 1, &amp;quot;eg_float&amp;quot;: 4.56})&lt;br /&gt;
&lt;br /&gt;
    # Update a single value in the ODB&lt;br /&gt;
    client.odb_set(&amp;quot;/pyexample/eg_float&amp;quot;, 5.67)&lt;br /&gt;
&lt;br /&gt;
    # Read the value back&lt;br /&gt;
    readback = client.odb_get(&amp;quot;/pyexample/eg_float&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    print(&amp;quot;The new value of /pyexample/eg_float is %f&amp;quot; % readback)&lt;br /&gt;
&lt;br /&gt;
    # Delete the temporary directory we created&lt;br /&gt;
    client.odb_delete(&amp;quot;/pyexample&amp;quot;)&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== midas.frontend ===&lt;br /&gt;
&lt;br /&gt;
Example of a basic midas frontend that has one periodic equipment. See &amp;lt;code&amp;gt;$MIDASSYS/examples/multi_frontend.py&amp;lt;/code&amp;gt; for an example that uses more features (frontend index, polled equipment, ODB settings etc). &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;import midas&lt;br /&gt;
import midas.frontend&lt;br /&gt;
import midas.event&lt;br /&gt;
&lt;br /&gt;
class MyPeriodicEquipment(midas.frontend.EquipmentBase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    We define an &amp;quot;equipment&amp;quot; for each logically distinct task that this frontend&lt;br /&gt;
    performs. For example, you may have one equipment for reading data from a&lt;br /&gt;
    device and sending it to a midas buffer, and another equipment that updates&lt;br /&gt;
    summary statistics every 10s.&lt;br /&gt;
    &lt;br /&gt;
    Each equipment class you define should inherit from &lt;br /&gt;
    `midas.frontend.EquipmentBase`, and should define a `readout_func` function.&lt;br /&gt;
    If you&#039;re creating a &amp;quot;polled&amp;quot; equipment (rather than a periodic one), you&lt;br /&gt;
    should also define a `poll_func` function in addition to `readout_func`.&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def __init__(self, client):&lt;br /&gt;
        # The name of our equipment. This name will be used on the midas status&lt;br /&gt;
        # page, and our info will appear in /Equipment/MyPeriodicEquipment in&lt;br /&gt;
        # the ODB.&lt;br /&gt;
        equip_name = &amp;quot;MyPeriodicEquipment&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        # Define the &amp;quot;common&amp;quot; settings of a frontend. These will appear in&lt;br /&gt;
        # /Equipment/MyPeriodicEquipment/Common. The values you set here are&lt;br /&gt;
        # only used the very first time this frontend/equipment runs; after &lt;br /&gt;
        # that the ODB settings are used.&lt;br /&gt;
        default_common = midas.frontend.InitialEquipmentCommon()&lt;br /&gt;
        default_common.equip_type = midas.EQ_PERIODIC&lt;br /&gt;
        default_common.buffer_name = &amp;quot;SYSTEM&amp;quot;&lt;br /&gt;
        default_common.trigger_mask = 0&lt;br /&gt;
        default_common.event_id = 1&lt;br /&gt;
        default_common.period_ms = 100&lt;br /&gt;
        default_common.read_when = midas.RO_RUNNING&lt;br /&gt;
        default_common.log_history = 1&lt;br /&gt;
        &lt;br /&gt;
        # You MUST call midas.frontend.EquipmentBase.__init__ in your equipment&#039;s __init__ method!&lt;br /&gt;
        midas.frontend.EquipmentBase.__init__(self, client, equip_name, default_common)&lt;br /&gt;
        &lt;br /&gt;
        # You can set the status of the equipment (appears in the midas status page)&lt;br /&gt;
        self.set_status(&amp;quot;Initialized&amp;quot;)&lt;br /&gt;
        &lt;br /&gt;
    def readout_func(self):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        For a periodic equipment, this function will be called periodically&lt;br /&gt;
        (every 100ms in this case). It should return either a `midas.event.Event`&lt;br /&gt;
        or None (if we shouldn&#039;t write an event).&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        &lt;br /&gt;
        # In this example, we just make a simple event with one bank.&lt;br /&gt;
        event = midas.event.Event()&lt;br /&gt;
        &lt;br /&gt;
        # Create a bank (called &amp;quot;MYBK&amp;quot;) which in this case will store 8 ints.&lt;br /&gt;
        # data can be a list, a tuple or a numpy array.&lt;br /&gt;
        data = [1,2,3,4,5,6,7,8]&lt;br /&gt;
        event.create_bank(&amp;quot;MYBK&amp;quot;, midas.TID_INT, data)&lt;br /&gt;
        &lt;br /&gt;
        return event&lt;br /&gt;
&lt;br /&gt;
class MyFrontend(midas.frontend.FrontendBase):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    A frontend contains a collection of equipment.&lt;br /&gt;
    You can access self.client to access the ODB etc (see `midas.client.MidasClient`).&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        # You must call __init__ from the base class.&lt;br /&gt;
        midas.frontend.FrontendBase.__init__(self, &amp;quot;myfe_name&amp;quot;)&lt;br /&gt;
        &lt;br /&gt;
        # You can add equipment at any time before you call `run()`, but doing&lt;br /&gt;
        # it in __init__() seems logical.&lt;br /&gt;
        self.add_equipment(MyPeriodicEquipment(self.client))&lt;br /&gt;
        &lt;br /&gt;
    def begin_of_run(self, run_number):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        This function will be called at the beginning of the run.&lt;br /&gt;
        You don&#039;t have to define it, but you probably should.&lt;br /&gt;
        You can access individual equipment classes through the `self.equipment`&lt;br /&gt;
        dict if needed.&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        self.set_all_equipment_status(&amp;quot;Running&amp;quot;, &amp;quot;greenLight&amp;quot;)&lt;br /&gt;
        self.client.msg(&amp;quot;Frontend has seen start of run number %d&amp;quot; % run_number)&lt;br /&gt;
        return midas.status_codes[&amp;quot;SUCCESS&amp;quot;]&lt;br /&gt;
        &lt;br /&gt;
    def end_of_run(self, run_number):&lt;br /&gt;
        self.set_all_equipment_status(&amp;quot;Finished&amp;quot;, &amp;quot;greenLight&amp;quot;)&lt;br /&gt;
        self.client.msg(&amp;quot;Frontend has seen end of run number %d&amp;quot; % run_number)&lt;br /&gt;
        return midas.status_codes[&amp;quot;SUCCESS&amp;quot;]&lt;br /&gt;
    &lt;br /&gt;
    def frontend_exit(self):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Most people won&#039;t need to define this function, but you can use&lt;br /&gt;
        it for final cleanup if needed.&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        print(&amp;quot;Goodbye from user code!&amp;quot;)&lt;br /&gt;
        &lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    # The main executable is very simple - just create the frontend object,&lt;br /&gt;
    # and call run() on it.&lt;br /&gt;
    with MyFrontend() as my_fe:&lt;br /&gt;
        my_fe.run()&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Doing work when the program exits ===&lt;br /&gt;
&lt;br /&gt;
Since April 2023, the python frontend framework has included the ability to ensure that work gets performed when the program exits (more specifically, just before we disconnect from midas). This may be useful, for example, to reset the state of some hardware before the program exits.&lt;br /&gt;
&lt;br /&gt;
In the frontend framework, this is done by implementing the &amp;lt;code&amp;gt;frontend_exit()&amp;lt;/code&amp;gt; function in your frontend class (see the example code above). If you&#039;re using a bare &amp;lt;code&amp;gt;MidasClient&amp;lt;/code&amp;gt; you can instead call &amp;lt;code&amp;gt;register_disconnect_callback()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To be certain that your function gets called, you should use the &amp;quot;context manager&amp;quot; style to create your client/frontend object.&lt;br /&gt;
&lt;br /&gt;
 # Context manager style - guaranteed that `frontend_exit()` will be called, even&lt;br /&gt;
 # if there&#039;s an uncaught exception or exit(0) is called etc.&lt;br /&gt;
 with MyFrontend() as my_fe:&lt;br /&gt;
     my_fe.run()&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 # Not using a context manager - `frontend_exit()` may NOT be called!&lt;br /&gt;
 my_fe = MyFrontend()&lt;br /&gt;
 my_fe.run()&lt;br /&gt;
&lt;br /&gt;
The reason for this is that the best we can do in the latter approach is to hook up the midas disconnection logic to the destructor of the &amp;lt;code&amp;gt;MidasClient&amp;lt;/code&amp;gt; object. But python does not guarantee that an object&#039;s &amp;lt;code&amp;gt;__del__()&amp;lt;/code&amp;gt; function will be called in a timely manner (or even at all!). It depends on your python version, python implementation, and if you do any weird things in your class (e.g. circular references).&lt;br /&gt;
&lt;br /&gt;
In the context manager approach, we can hook up the midas disconnection logic to the &amp;lt;code&amp;gt;__exit__()&amp;lt;/code&amp;gt; function, which python DOES guarantee will be called.&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;$MIDASSYS/python/tests&amp;lt;/code&amp;gt; contains a variety of test scripts. If you wish, you can run them using&lt;br /&gt;
&lt;br /&gt;
 cd $MIDASSYS/python/tests&lt;br /&gt;
 python -munittest&lt;br /&gt;
&lt;br /&gt;
However, note that running these tests will interact with whichever midas experiment is currently active. They will edit the ODB and start and stop runs. If you are running these tests, we suggest doing so in a &amp;quot;dummy&amp;quot;/test experiment.&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=3639</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=3639"/>
		<updated>2026-09-29T16:13:18Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install standalone elog */&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://gitlab.triumf.ca/midas/midas.git --recursive&lt;br /&gt;
* (OBSOLETE) git clone https://gitlab.triumf.ca/midas/mxml.git&lt;br /&gt;
* (OBSOLETE) git clone https://gitlab.triumf.ca/midas/mscb.git&lt;br /&gt;
* (IF GITLAB IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mxml.git&lt;br /&gt;
* (IF GITLAB IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mscb.git&lt;br /&gt;
* (IF GITLAB 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://gitlab.triumf.ca/midas/rootana.git&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://gitlab.triumf.ca/midas/roody.git&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://gitea.psi.ch/ELOG/elog.git&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=3638</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=3638"/>
		<updated>2026-09-29T16:11:35Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install ROODY */&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://gitlab.triumf.ca/midas/midas.git --recursive&lt;br /&gt;
* (OBSOLETE) git clone https://gitlab.triumf.ca/midas/mxml.git&lt;br /&gt;
* (OBSOLETE) git clone https://gitlab.triumf.ca/midas/mscb.git&lt;br /&gt;
* (IF GITLAB IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mxml.git&lt;br /&gt;
* (IF GITLAB IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mscb.git&lt;br /&gt;
* (IF GITLAB 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://gitlab.triumf.ca/midas/rootana.git&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://gitlab.triumf.ca/midas/roody.git&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=3637</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=3637"/>
		<updated>2026-09-29T16:11:13Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install ROOTANA */&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://gitlab.triumf.ca/midas/midas.git --recursive&lt;br /&gt;
* (OBSOLETE) git clone https://gitlab.triumf.ca/midas/mxml.git&lt;br /&gt;
* (OBSOLETE) git clone https://gitlab.triumf.ca/midas/mscb.git&lt;br /&gt;
* (IF GITLAB IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mxml.git&lt;br /&gt;
* (IF GITLAB IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mscb.git&lt;br /&gt;
* (IF GITLAB 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://gitlab.triumf.ca/midas/rootana.git&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=3636</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=3636"/>
		<updated>2026-09-29T16:10:49Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Install MIDAS */&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://gitlab.triumf.ca/midas/midas.git --recursive&lt;br /&gt;
* (OBSOLETE) git clone https://gitlab.triumf.ca/midas/mxml.git&lt;br /&gt;
* (OBSOLETE) git clone https://gitlab.triumf.ca/midas/mscb.git&lt;br /&gt;
* (IF GITLAB IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mxml.git&lt;br /&gt;
* (IF GITLAB IS DOWN) git clone -v --progress https://daq.triumf.ca/~daqweb/git/mscb.git&lt;br /&gt;
* (IF GITLAB 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=Introduction&amp;diff=3635</id>
		<title>Introduction</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Introduction&amp;diff=3635"/>
		<updated>2026-09-29T16:09:15Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* History */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== What is Midas ==&lt;br /&gt;
&amp;quot;MIDAS&amp;quot; is an acronym for Maximum Integrated Data Acquisition System. &lt;br /&gt;
&lt;br /&gt;
MIDAS is a general-purpose system for event-based data acquisition in small and medium scale Physics experiments. It is an on-going development at the Paul Scherrer Institute (Switzerland) and at TRIUMF (Canada), since 1993. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; It is not to be confused with MIDAS (Multi Instance Data Acquisition System) from UK, or any of the MIDAS (Mobile Instrumentation Data Acquisition System), or MIDAS digital and analogue consoles and finally with MIDAS Brakes and Mufflers! &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
MIDAS is based on a modular networking capability and a central database system. MIDAS consists of a C library and several applications, which can run on many different platforms (i.e. operating systems) mainly UNIX-like based (we use to support Windows, VMS...). While the system is already in use in many laboratories, the development continues with addition of new features and tools. Recent developments involve multi-threading, FGPA/Linux support, MSCB extension.&lt;br /&gt;
&lt;br /&gt;
==What Midas can do for you ==&lt;br /&gt;
In a few words, Midas can:&lt;br /&gt;
* &#039;&#039;&#039;Collect data from local and/or remote clients.&#039;&#039;&#039;&lt;br /&gt;
* Provides a mean to configure the hardware managed by any of the client ([[Online_Database| Online database]])&lt;br /&gt;
* Manages the [[Run_States_and_Transitions | run transitions]] functions during run operation (start, stop, etc.) &lt;br /&gt;
* Provides a set of essential [[Application_listing| Applications]] to control and monitor a data acquisition sequence.&lt;br /&gt;
* Implements [[Feature_listing | features ]]) specific to Data Aquisition for physics experiment.&lt;br /&gt;
* Records the collected data to various [[mlogger|storage media]].&lt;br /&gt;
* Provides programming interfaces of the data stream to different analysis packages ([[ROOTANA]], [http://bitbucket.org/tmidas/manalyzer/src/master/ manalyzer]).&lt;br /&gt;
* Provides a web interface and tools to build custom display for run monitoring and control ([[mhttpd]], [[Status_Page]]).&lt;br /&gt;
&lt;br /&gt;
==History==&lt;br /&gt;
In the early &#039;90s, based on a previous Data Acquisition system running under MS-DOS with network capability (HIX), Dr. Stefan Ritt at Paul Sherrer Institute PSI (Switzerland) started coding a new set of applications which would be OS independent. At that time, OS such as VMS, ULTRIX, VxWorks and Windows were available.&lt;br /&gt;
The first deployment of Midas was for the &amp;quot;Canadian High Acceptance Orbital Spectrometer&amp;quot; (CHAOS) experimental facility at TRIUMF (Canada). Network based, the data were collected from a VME processor running VxWorks (collecting CAMAC, FastBus &amp;amp; VME data) and sending them to a backend computer running VMS and later ULTRIX.&lt;br /&gt;
&lt;br /&gt;
Since then, Midas has been deployed on all major experiments at TRIUMF and PSI. It is also used around the world in over 80 locations. From simple workbench test setups to world class experiments such as PiBeta - muon decay [http://meg.icepp.s.u-tokyo.ac.jp/ &#039;&#039;&#039;MEG&#039;&#039;&#039;] (PSI, Switzerland) - trapping antihydrogen atoms [http://alpha.web.cern.ch/ &#039;&#039;&#039;ALPHA&#039;&#039;&#039;, &#039;&#039;&#039;ALPHA-g&#039;&#039;&#039;] (CERN, Switzerland) - neutrino oscillation [http://t2k-experiment.org/ &#039;&#039;&#039;T2K&#039;&#039;&#039;](J-Parc, Japan) - Decay study Pienu - precision muon measurement Twist (TRIUMF, Canada) - Dark Matter search [http://deap.phy.queensu.ca/ &#039;&#039;&#039;DEAP&#039;&#039;&#039;] (Sudbury, Canada) - Neutron Capture DANCE (Los Alamos, USA), - Dark Matter search [https://surfacetreatments.infn.it/projects/darkside-20k-project/ &#039;&#039;&#039;DARKIDE-20K&#039;&#039;&#039;] (LNGS, Italy), - P-ONE neutrino telescope [https://www.pacific-neutrino.org/ &#039;&#039;&#039;P-ONE&#039;&#039;&#039;] (Cascadia Basin, Canada), - P-ONE neutrino telescope [https://nexo.llnl.gov/ &#039;&#039;&#039;nEXO&#039;&#039;&#039;] (Subury, Canada)&lt;br /&gt;
&lt;br /&gt;
Midas has demonstrated its versatile capabilities and proven to be a mature and modern Data Acquisition Software package.&lt;br /&gt;
A non-exhaustive list of experiments can be found [https://midas.triumf.ca/MidasWiki/index.php/MIDAS_around_the_world here].&lt;br /&gt;
&lt;br /&gt;
=== Recent Developments ===https://www.pacific-neutrino.org/p-one&lt;br /&gt;
* July 2013 : Stefan Ritt visit at Triumf&lt;br /&gt;
** Midas code from local SVN repository to Bitbucket cloud based GIT repository [https://bitbucket.org/tmidas/midas Tmidas]&lt;br /&gt;
** Implementation of multi-threading transition&lt;br /&gt;
** New Midas web page&lt;br /&gt;
** JSON, JSON-P for custom Midas web page support&lt;br /&gt;
*Jan 2014 : New History Logging scheme &amp;quot;FILE&amp;quot;&lt;br /&gt;
* July 2015 : Stefan Ritt visit at Triumf&lt;br /&gt;
* August 2015 : Important Network Security upgrades: &lt;br /&gt;
** Default MIDAS is now secure (clients must run on localhost only) &lt;br /&gt;
** Network connections must be explicity allowed (see [[Security]])&lt;br /&gt;
** [[mhttpd]] uses secure HTTPS connections&lt;br /&gt;
* January 2016 : mjson-rpc functions added to Javascript libary [[mhttpd.js]] - see [[mjsonrpc]]&lt;br /&gt;
* July 2017&lt;br /&gt;
** New web page layout with menu buttons on left side and alarm and message display on every page&lt;br /&gt;
** New custom pages based on the mjson-rpc layer - see [[Custom_Page|Custom Pages 2017]]&lt;br /&gt;
* September 2026&lt;br /&gt;
** Migrated to [https://gitlab.triumf.ca/midas/midas TRIUMF-hosted gitlab]&lt;br /&gt;
&lt;br /&gt;
==[[Overall Midas system diagram]]==&lt;br /&gt;
A graphical view of the generic acquisition components forming the MIDAS DAQ&lt;br /&gt;
&lt;br /&gt;
==[[Midas Core]]==&lt;br /&gt;
A general description of the different components composing the Midas Data Acquisition package&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=ROOTANA&amp;diff=3634</id>
		<title>ROOTANA</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=ROOTANA&amp;diff=3634"/>
		<updated>2026-09-29T16:08:18Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Contacts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
&lt;br /&gt;
* [[ROOT]]&lt;br /&gt;
* https://gitlab.triumf.ca/midas/rootana&lt;br /&gt;
* git clone https://gitlab.triumf.ca/midas/rootana.git&lt;br /&gt;
* git clone http://ladd00.triumf.ca/~daqweb/git/rootana.git&lt;br /&gt;
* (obsolete) [https://ladd00.triumf.ca/viewvc/rootana/trunk ROOTANA SVN reporitory] (username svn, password svn)&lt;br /&gt;
* [http://ladd00.triumf.ca/~daqweb/doc/rootana/html ROOTANA Doxygen documentation]&lt;br /&gt;
&lt;br /&gt;
= Download and Quick start =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo $ROOTSYS # check correct installation of ROOT&lt;br /&gt;
root-config # check correct installation of ROOT&lt;br /&gt;
&lt;br /&gt;
git clone https://gitlab.triumf.ca/midas/rootana.git&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
make dox&lt;br /&gt;
&lt;br /&gt;
more analyzer.cxx&lt;br /&gt;
more event_dump.cxx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
Welcome to ROOTANA, the ROOT (https://root.cern.ch) based data analysis package for the MIDAS Data Acquisition system (https://midas.triumf.ca).&lt;br /&gt;
&lt;br /&gt;
The ROOTANA package includes 5 major components:&lt;br /&gt;
* a standalone library for reading and writing data files in the MIDAS .mid format, and for decoding the XML dump of MIDAS ODB typically embedded in every MIDAS data file. (libMidasInterface)&lt;br /&gt;
* a C++ interface class for connecting to an active MIDAS experiment, accessing ODB (read and write) and getting event data. (libMidasInterface)&lt;br /&gt;
* a set of C++ classes for exporting ROOT histogram and other objects to an external viewer for interactive visualization of live data, typically using the  ROODY histogram viewer or using a standard web browser (experimental feature). (libMidasServer, libNetDirectory, libXmlServer)&lt;br /&gt;
* simple examples of using these components (a graphical analyzer, an event dump and an event skim programs) (analyzer.cxx, event_dump.cxx, event_skim.cxx)&lt;br /&gt;
* a full featured framework for graphical data analysis including code to unpack typical VME and CAMAC modules ( see [[rootana Analyzer Framework]] and [[rootana Display Framework]])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The ROOTANA package can be used without installing ROOT and MIDAS:&lt;br /&gt;
* without both ROOT and MIDAS one can only read (and write) existing .mid files. Only event_dump and event_skim will be built.&lt;br /&gt;
* if only the MIDAS package is installed, access to live data and access to live ODB becomes possible. Only event_dump and event_skim will be built.&lt;br /&gt;
* decoding of XML ODB dumps embedded in MIDAS files requires ROOT TXML and TDOMParser components (a version of XML decoder using libxml2 used to exist in the past).&lt;br /&gt;
* if the ROOT package is installed but MIDAS is absent, full function of ROOTANA is available, except for access to live data. This mode is suitable for offline data analysis, i.e. the user has a copy of MIDAS data files on their laptop and wants to analyze them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The sources for ROOTANA are managed at https://gitlab.triumf.ca/midas/rootana.&lt;br /&gt;
&lt;br /&gt;
= Components =&lt;br /&gt;
&lt;br /&gt;
== MIDAS Interface ==&lt;br /&gt;
&lt;br /&gt;
These classes provide the actual access to MIDAS data&lt;br /&gt;
&lt;br /&gt;
* TMidasEvent: a class encapulating a MIDAS event.&lt;br /&gt;
* TMidasFile: a class encapsulating a MIDAS file &lt;br /&gt;
* TMidasOnline: a class that allows access to online MIDAS events; this class requires that the MIDAS libraries be installed&lt;br /&gt;
* VirtualODB: a class that provides access to ODB variables, either through ODB dumps at the start of files or by directly connecting to the online ODB.&lt;br /&gt;
&lt;br /&gt;
== XML Server ==&lt;br /&gt;
&lt;br /&gt;
xmlServer &amp;amp; co&lt;br /&gt;
&lt;br /&gt;
== example programs ==&lt;br /&gt;
&lt;br /&gt;
* event_dump&lt;br /&gt;
* event_skim&lt;br /&gt;
* standalone graphical analyzer.cxx&lt;br /&gt;
&lt;br /&gt;
== ROOT Analyzer framework ==&lt;br /&gt;
&lt;br /&gt;
rootana provides low-level access to the MIDAS data files and online MIDAS data.  Using these low-level functionality users can design whatever sort of programs they want for accessing and analyzing the data.&lt;br /&gt;
&lt;br /&gt;
rootana also provides a more structured, higher-level framework for organizing analysis programs.  The framework includes a standard event loop class and a standard display program.  Details on this higher-level framework available in [[rootana Analyzer Framework]] and  [[rootana Display Framework]].&lt;br /&gt;
&lt;br /&gt;
= Contacts = &lt;br /&gt;
&lt;br /&gt;
* Before conversion from svn to git, ROOTANA was managed by members of the TRIUMF DAQ group&lt;br /&gt;
* The git version hosted on the TRIUMF gitlab is managed by the members of the MIDAS developers group.&lt;br /&gt;
* to report bugs, request improvements, contribute bug fixes - please go to the ROOTANA issue tracker https://gitlab.triumf.ca/midas/rootana/-/work_items&lt;br /&gt;
* for questions and discussion - please go to the MIDAS discussion forum https://midas.triumf.ca/forum&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=ROOTANA&amp;diff=3633</id>
		<title>ROOTANA</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=ROOTANA&amp;diff=3633"/>
		<updated>2026-09-29T16:07:46Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
&lt;br /&gt;
* [[ROOT]]&lt;br /&gt;
* https://gitlab.triumf.ca/midas/rootana&lt;br /&gt;
* git clone https://gitlab.triumf.ca/midas/rootana.git&lt;br /&gt;
* git clone http://ladd00.triumf.ca/~daqweb/git/rootana.git&lt;br /&gt;
* (obsolete) [https://ladd00.triumf.ca/viewvc/rootana/trunk ROOTANA SVN reporitory] (username svn, password svn)&lt;br /&gt;
* [http://ladd00.triumf.ca/~daqweb/doc/rootana/html ROOTANA Doxygen documentation]&lt;br /&gt;
&lt;br /&gt;
= Download and Quick start =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo $ROOTSYS # check correct installation of ROOT&lt;br /&gt;
root-config # check correct installation of ROOT&lt;br /&gt;
&lt;br /&gt;
git clone https://gitlab.triumf.ca/midas/rootana.git&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
make dox&lt;br /&gt;
&lt;br /&gt;
more analyzer.cxx&lt;br /&gt;
more event_dump.cxx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
Welcome to ROOTANA, the ROOT (https://root.cern.ch) based data analysis package for the MIDAS Data Acquisition system (https://midas.triumf.ca).&lt;br /&gt;
&lt;br /&gt;
The ROOTANA package includes 5 major components:&lt;br /&gt;
* a standalone library for reading and writing data files in the MIDAS .mid format, and for decoding the XML dump of MIDAS ODB typically embedded in every MIDAS data file. (libMidasInterface)&lt;br /&gt;
* a C++ interface class for connecting to an active MIDAS experiment, accessing ODB (read and write) and getting event data. (libMidasInterface)&lt;br /&gt;
* a set of C++ classes for exporting ROOT histogram and other objects to an external viewer for interactive visualization of live data, typically using the  ROODY histogram viewer or using a standard web browser (experimental feature). (libMidasServer, libNetDirectory, libXmlServer)&lt;br /&gt;
* simple examples of using these components (a graphical analyzer, an event dump and an event skim programs) (analyzer.cxx, event_dump.cxx, event_skim.cxx)&lt;br /&gt;
* a full featured framework for graphical data analysis including code to unpack typical VME and CAMAC modules ( see [[rootana Analyzer Framework]] and [[rootana Display Framework]])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The ROOTANA package can be used without installing ROOT and MIDAS:&lt;br /&gt;
* without both ROOT and MIDAS one can only read (and write) existing .mid files. Only event_dump and event_skim will be built.&lt;br /&gt;
* if only the MIDAS package is installed, access to live data and access to live ODB becomes possible. Only event_dump and event_skim will be built.&lt;br /&gt;
* decoding of XML ODB dumps embedded in MIDAS files requires ROOT TXML and TDOMParser components (a version of XML decoder using libxml2 used to exist in the past).&lt;br /&gt;
* if the ROOT package is installed but MIDAS is absent, full function of ROOTANA is available, except for access to live data. This mode is suitable for offline data analysis, i.e. the user has a copy of MIDAS data files on their laptop and wants to analyze them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The sources for ROOTANA are managed at https://gitlab.triumf.ca/midas/rootana.&lt;br /&gt;
&lt;br /&gt;
= Components =&lt;br /&gt;
&lt;br /&gt;
== MIDAS Interface ==&lt;br /&gt;
&lt;br /&gt;
These classes provide the actual access to MIDAS data&lt;br /&gt;
&lt;br /&gt;
* TMidasEvent: a class encapulating a MIDAS event.&lt;br /&gt;
* TMidasFile: a class encapsulating a MIDAS file &lt;br /&gt;
* TMidasOnline: a class that allows access to online MIDAS events; this class requires that the MIDAS libraries be installed&lt;br /&gt;
* VirtualODB: a class that provides access to ODB variables, either through ODB dumps at the start of files or by directly connecting to the online ODB.&lt;br /&gt;
&lt;br /&gt;
== XML Server ==&lt;br /&gt;
&lt;br /&gt;
xmlServer &amp;amp; co&lt;br /&gt;
&lt;br /&gt;
== example programs ==&lt;br /&gt;
&lt;br /&gt;
* event_dump&lt;br /&gt;
* event_skim&lt;br /&gt;
* standalone graphical analyzer.cxx&lt;br /&gt;
&lt;br /&gt;
== ROOT Analyzer framework ==&lt;br /&gt;
&lt;br /&gt;
rootana provides low-level access to the MIDAS data files and online MIDAS data.  Using these low-level functionality users can design whatever sort of programs they want for accessing and analyzing the data.&lt;br /&gt;
&lt;br /&gt;
rootana also provides a more structured, higher-level framework for organizing analysis programs.  The framework includes a standard event loop class and a standard display program.  Details on this higher-level framework available in [[rootana Analyzer Framework]] and  [[rootana Display Framework]].&lt;br /&gt;
&lt;br /&gt;
= Contacts = &lt;br /&gt;
&lt;br /&gt;
* Before conversion from svn to git, ROOTANA was managed by members of the TRIUMF DAQ group&lt;br /&gt;
* The git version hosted on bitbucket is managed by the members of the MIDAS developers group.&lt;br /&gt;
* to report bugs, request improvements, contribute bug fixes - please go to the ROOTANA issue tracker https://bitbucket.org/tmidas/rootana/issues&lt;br /&gt;
* for questions and discussion - please go to the MIDAS discussion forum https://midas.triumf.ca/forum&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=ROOTANA&amp;diff=3632</id>
		<title>ROOTANA</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=ROOTANA&amp;diff=3632"/>
		<updated>2026-09-29T16:07:25Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Download and Quick start */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
&lt;br /&gt;
* [[ROOT]]&lt;br /&gt;
* https://gitlab.triumf.ca/midas/rootana&lt;br /&gt;
* git clone https://gitlab.triumf.ca/midas/rootana.git&lt;br /&gt;
* git clone http://ladd00.triumf.ca/~daqweb/git/rootana.git&lt;br /&gt;
* (obsolete) [https://ladd00.triumf.ca/viewvc/rootana/trunk ROOTANA SVN reporitory] (username svn, password svn)&lt;br /&gt;
* [http://ladd00.triumf.ca/~daqweb/doc/rootana/html ROOTANA Doxygen documentation]&lt;br /&gt;
&lt;br /&gt;
= Download and Quick start =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo $ROOTSYS # check correct installation of ROOT&lt;br /&gt;
root-config # check correct installation of ROOT&lt;br /&gt;
&lt;br /&gt;
git clone https://gitlab.triumf.ca/midas/rootana.git&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
make dox&lt;br /&gt;
&lt;br /&gt;
more analyzer.cxx&lt;br /&gt;
more event_dump.cxx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
Welcome to ROOTANA, the ROOT (https://root.cern.ch) based data analysis package for the MIDAS Data Acquisition system (https://midas.triumf.ca).&lt;br /&gt;
&lt;br /&gt;
The ROOTANA package includes 5 major components:&lt;br /&gt;
* a standalone library for reading and writing data files in the MIDAS .mid format, and for decoding the XML dump of MIDAS ODB typically embedded in every MIDAS data file. (libMidasInterface)&lt;br /&gt;
* a C++ interface class for connecting to an active MIDAS experiment, accessing ODB (read and write) and getting event data. (libMidasInterface)&lt;br /&gt;
* a set of C++ classes for exporting ROOT histogram and other objects to an external viewer for interactive visualization of live data, typically using the  ROODY histogram viewer or using a standard web browser (experimental feature). (libMidasServer, libNetDirectory, libXmlServer)&lt;br /&gt;
* simple examples of using these components (a graphical analyzer, an event dump and an event skim programs) (analyzer.cxx, event_dump.cxx, event_skim.cxx)&lt;br /&gt;
* a full featured framework for graphical data analysis including code to unpack typical VME and CAMAC modules ( see [[rootana Analyzer Framework]] and [[rootana Display Framework]])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The ROOTANA package can be used without installing ROOT and MIDAS:&lt;br /&gt;
* without both ROOT and MIDAS one can only read (and write) existing .mid files. Only event_dump and event_skim will be built.&lt;br /&gt;
* if only the MIDAS package is installed, access to live data and access to live ODB becomes possible. Only event_dump and event_skim will be built.&lt;br /&gt;
* decoding of XML ODB dumps embedded in MIDAS files requires ROOT TXML and TDOMParser components (a version of XML decoder using libxml2 used to exist in the past).&lt;br /&gt;
* if the ROOT package is installed but MIDAS is absent, full function of ROOTANA is available, except for access to live data. This mode is suitable for offline data analysis, i.e. the user has a copy of MIDAS data files on their laptop and wants to analyze them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The sources for ROOTANA are managed at https://bitbucket.org/tmidas/rootana.&lt;br /&gt;
&lt;br /&gt;
= Components =&lt;br /&gt;
&lt;br /&gt;
== MIDAS Interface ==&lt;br /&gt;
&lt;br /&gt;
These classes provide the actual access to MIDAS data&lt;br /&gt;
&lt;br /&gt;
* TMidasEvent: a class encapulating a MIDAS event.&lt;br /&gt;
* TMidasFile: a class encapsulating a MIDAS file &lt;br /&gt;
* TMidasOnline: a class that allows access to online MIDAS events; this class requires that the MIDAS libraries be installed&lt;br /&gt;
* VirtualODB: a class that provides access to ODB variables, either through ODB dumps at the start of files or by directly connecting to the online ODB.&lt;br /&gt;
&lt;br /&gt;
== XML Server ==&lt;br /&gt;
&lt;br /&gt;
xmlServer &amp;amp; co&lt;br /&gt;
&lt;br /&gt;
== example programs ==&lt;br /&gt;
&lt;br /&gt;
* event_dump&lt;br /&gt;
* event_skim&lt;br /&gt;
* standalone graphical analyzer.cxx&lt;br /&gt;
&lt;br /&gt;
== ROOT Analyzer framework ==&lt;br /&gt;
&lt;br /&gt;
rootana provides low-level access to the MIDAS data files and online MIDAS data.  Using these low-level functionality users can design whatever sort of programs they want for accessing and analyzing the data.&lt;br /&gt;
&lt;br /&gt;
rootana also provides a more structured, higher-level framework for organizing analysis programs.  The framework includes a standard event loop class and a standard display program.  Details on this higher-level framework available in [[rootana Analyzer Framework]] and  [[rootana Display Framework]].&lt;br /&gt;
&lt;br /&gt;
= Contacts = &lt;br /&gt;
&lt;br /&gt;
* Before conversion from svn to git, ROOTANA was managed by members of the TRIUMF DAQ group&lt;br /&gt;
* The git version hosted on bitbucket is managed by the members of the MIDAS developers group.&lt;br /&gt;
* to report bugs, request improvements, contribute bug fixes - please go to the ROOTANA issue tracker https://bitbucket.org/tmidas/rootana/issues&lt;br /&gt;
* for questions and discussion - please go to the MIDAS discussion forum https://midas.triumf.ca/forum&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=ROOTANA&amp;diff=3631</id>
		<title>ROOTANA</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=ROOTANA&amp;diff=3631"/>
		<updated>2026-09-29T16:07:09Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Pagelinks}}&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
&lt;br /&gt;
* [[ROOT]]&lt;br /&gt;
* https://gitlab.triumf.ca/midas/rootana&lt;br /&gt;
* git clone https://gitlab.triumf.ca/midas/rootana.git&lt;br /&gt;
* git clone http://ladd00.triumf.ca/~daqweb/git/rootana.git&lt;br /&gt;
* (obsolete) [https://ladd00.triumf.ca/viewvc/rootana/trunk ROOTANA SVN reporitory] (username svn, password svn)&lt;br /&gt;
* [http://ladd00.triumf.ca/~daqweb/doc/rootana/html ROOTANA Doxygen documentation]&lt;br /&gt;
&lt;br /&gt;
= Download and Quick start =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
echo $ROOTSYS # check correct installation of ROOT&lt;br /&gt;
root-config # check correct installation of ROOT&lt;br /&gt;
&lt;br /&gt;
git clone https://bitbucket.org/tmidas/rootana.git&lt;br /&gt;
cd rootana&lt;br /&gt;
make&lt;br /&gt;
make dox&lt;br /&gt;
&lt;br /&gt;
more analyzer.cxx&lt;br /&gt;
more event_dump.cxx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
Welcome to ROOTANA, the ROOT (https://root.cern.ch) based data analysis package for the MIDAS Data Acquisition system (https://midas.triumf.ca).&lt;br /&gt;
&lt;br /&gt;
The ROOTANA package includes 5 major components:&lt;br /&gt;
* a standalone library for reading and writing data files in the MIDAS .mid format, and for decoding the XML dump of MIDAS ODB typically embedded in every MIDAS data file. (libMidasInterface)&lt;br /&gt;
* a C++ interface class for connecting to an active MIDAS experiment, accessing ODB (read and write) and getting event data. (libMidasInterface)&lt;br /&gt;
* a set of C++ classes for exporting ROOT histogram and other objects to an external viewer for interactive visualization of live data, typically using the  ROODY histogram viewer or using a standard web browser (experimental feature). (libMidasServer, libNetDirectory, libXmlServer)&lt;br /&gt;
* simple examples of using these components (a graphical analyzer, an event dump and an event skim programs) (analyzer.cxx, event_dump.cxx, event_skim.cxx)&lt;br /&gt;
* a full featured framework for graphical data analysis including code to unpack typical VME and CAMAC modules ( see [[rootana Analyzer Framework]] and [[rootana Display Framework]])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The ROOTANA package can be used without installing ROOT and MIDAS:&lt;br /&gt;
* without both ROOT and MIDAS one can only read (and write) existing .mid files. Only event_dump and event_skim will be built.&lt;br /&gt;
* if only the MIDAS package is installed, access to live data and access to live ODB becomes possible. Only event_dump and event_skim will be built.&lt;br /&gt;
* decoding of XML ODB dumps embedded in MIDAS files requires ROOT TXML and TDOMParser components (a version of XML decoder using libxml2 used to exist in the past).&lt;br /&gt;
* if the ROOT package is installed but MIDAS is absent, full function of ROOTANA is available, except for access to live data. This mode is suitable for offline data analysis, i.e. the user has a copy of MIDAS data files on their laptop and wants to analyze them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The sources for ROOTANA are managed at https://bitbucket.org/tmidas/rootana.&lt;br /&gt;
&lt;br /&gt;
= Components =&lt;br /&gt;
&lt;br /&gt;
== MIDAS Interface ==&lt;br /&gt;
&lt;br /&gt;
These classes provide the actual access to MIDAS data&lt;br /&gt;
&lt;br /&gt;
* TMidasEvent: a class encapulating a MIDAS event.&lt;br /&gt;
* TMidasFile: a class encapsulating a MIDAS file &lt;br /&gt;
* TMidasOnline: a class that allows access to online MIDAS events; this class requires that the MIDAS libraries be installed&lt;br /&gt;
* VirtualODB: a class that provides access to ODB variables, either through ODB dumps at the start of files or by directly connecting to the online ODB.&lt;br /&gt;
&lt;br /&gt;
== XML Server ==&lt;br /&gt;
&lt;br /&gt;
xmlServer &amp;amp; co&lt;br /&gt;
&lt;br /&gt;
== example programs ==&lt;br /&gt;
&lt;br /&gt;
* event_dump&lt;br /&gt;
* event_skim&lt;br /&gt;
* standalone graphical analyzer.cxx&lt;br /&gt;
&lt;br /&gt;
== ROOT Analyzer framework ==&lt;br /&gt;
&lt;br /&gt;
rootana provides low-level access to the MIDAS data files and online MIDAS data.  Using these low-level functionality users can design whatever sort of programs they want for accessing and analyzing the data.&lt;br /&gt;
&lt;br /&gt;
rootana also provides a more structured, higher-level framework for organizing analysis programs.  The framework includes a standard event loop class and a standard display program.  Details on this higher-level framework available in [[rootana Analyzer Framework]] and  [[rootana Display Framework]].&lt;br /&gt;
&lt;br /&gt;
= Contacts = &lt;br /&gt;
&lt;br /&gt;
* Before conversion from svn to git, ROOTANA was managed by members of the TRIUMF DAQ group&lt;br /&gt;
* The git version hosted on bitbucket is managed by the members of the MIDAS developers group.&lt;br /&gt;
* to report bugs, request improvements, contribute bug fixes - please go to the ROOTANA issue tracker https://bitbucket.org/tmidas/rootana/issues&lt;br /&gt;
* for questions and discussion - please go to the MIDAS discussion forum https://midas.triumf.ca/forum&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3630</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3630"/>
		<updated>2026-09-29T16:06:05Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Documentation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
MIDAS is a modern data acquisition system developed at [http://www.psi.ch PSI] and [http://www.triumf.ca TRIUMF]. Supported hardware includes VME, Fastbus, CAMAC, RS232, GPIB, USB, ethernet, fiber optic and MSCB attached data acquisition devices. MIDAS is written in C/C++ and runs on Linux, MacOS and MS Windows. It is licensed under the [http://www.gnu.org/copyleft/gpl.html GNU Public License].&lt;br /&gt;
[[Introduction|&#039;&#039;&#039;more...&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
= Documentation =&lt;br /&gt;
&lt;br /&gt;
* [[Midas documentation| Main Documentation]]&lt;br /&gt;
* [[Installation | Installation Instructions]]&lt;br /&gt;
* [[Changelog | Changelog / Upgrade Instructions]]&lt;br /&gt;
* [https://daq.triumf.ca/~daqweb/doc/midas-develop/html/modules.html &amp;lt;i&amp;gt;Doxygen&amp;lt;/i&amp;gt;] Code structure, functions, etc...&lt;br /&gt;
* [https://gitlab.triumf.ca/midas/midas git repository on gitlab] Source code, bug tracking, etc&lt;br /&gt;
* [https://midas.triumf.ca/forum MIDAS forum] Discussion, announcements, problem reports, requests for improvements&lt;br /&gt;
* [https://dsdaqgw.triumf.ca/zensical MIDAS documentation] pre-production early access to new documentation&lt;br /&gt;
&lt;br /&gt;
= News and Support=&lt;br /&gt;
&lt;br /&gt;
For news about bug fixes and new releases, go to the&lt;br /&gt;
[https://midas.triumf.ca/forum MIDAS forum] hosted by TRIUMF using&lt;br /&gt;
the [http://elog.psi.ch/elog ELOG] system. Users can register in this system to be notified automatically via &lt;br /&gt;
E-mail when new entries are submitted.&lt;br /&gt;
&lt;br /&gt;
Another source of information is the [https://gitlab.triumf.ca/midas/midas Gitlab Repository] of MIDAS, where one can see the latest changes to the software.&lt;br /&gt;
&lt;br /&gt;
Finally, you can read presentations from&lt;br /&gt;
* [https://indico.psi.ch/conferenceDisplay.py?ovw=True&amp;amp;confId=3793 2015 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/428/ 2017 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/429/ 2019 MIDAS Workshop]&lt;br /&gt;
* [[2023 MIDAS Workshop]]&lt;br /&gt;
* [[2025 MIDAS Workshop]]&lt;br /&gt;
&lt;br /&gt;
= Related packages =&lt;br /&gt;
&lt;br /&gt;
* [http://elog.psi.ch/elog ELOG] - Electronics Logbook from PSI&lt;br /&gt;
* [https://bitbucket.org/tmidas/manalyzer/src/master/ manalyzer] - data analysis from TRIUMF&lt;br /&gt;
* [[ROOT]] - data analysis package from CERN&lt;br /&gt;
* [[ROOTANA]] - ROOT-based analyzer for MIDAS&lt;br /&gt;
* [[ROODY]] - viewer for online histograms&lt;br /&gt;
* http://elog.psi.ch/rome/ - MEG/PSI data analysis package&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=History&amp;diff=3629</id>
		<title>History</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=History&amp;diff=3629"/>
		<updated>2026-09-29T16:05:35Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* Current state of development */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
MIDAS has been created by Stefan Ritt at Paul Sherrer Institute in Aargau, Switzerland in the early 1990s in collaboration with Pierre-Andre Amaudruz from Triumf in Vancouver, Canada.&lt;br /&gt;
Since then a collective participate to the improvment of this DAQ software package in particular Konstantin Olchanski, Suzannah Daviel from Triumf and ... PSI&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Where this system is used ==&lt;br /&gt;
Midas is used across all the continents for a simple setup on the lab workbench to a full blown intermediate physics experiments such as muon decay [http://meg.icepp.s.u-tokyo.ac.jp/ &#039;&#039;&#039;MEG&#039;&#039;&#039;], neutrino oscillation [http://t2k-experiment.org/ &#039;&#039;&#039;T2K&#039;&#039;&#039;], trapping antihydrogen atoms [http://alpha.web.cern.ch/ &#039;&#039;&#039;ALPHA&#039;&#039;&#039;] or dark matter search [http://deap.phy.queensu.ca/ &#039;&#039;&#039;DEAP&#039;&#039;&#039;].&lt;br /&gt;
&lt;br /&gt;
A none exhaustive list of experiments can be found [https://midas.triumf.ca/MidasWiki/index.php/MIDAS_around_the_world here].&lt;br /&gt;
&lt;br /&gt;
== Current state of development ==&lt;br /&gt;
This section list the latest news about Midas code management and development.&lt;br /&gt;
&lt;br /&gt;
* September 2026&lt;br /&gt;
** Midas code migrated to gitlab server hosted by TRIUMF [https://gitlab.triumf.ca/midas/midas]&lt;br /&gt;
* July 2013 : Stefan visit at Triumf&lt;br /&gt;
**  We moved the Midas code from a local SVN repository to BitBucket cloud based GIT repository [https://bitbucket.org/tmidas Midas]&lt;br /&gt;
** Moving towards JSON, JSON-P for custom Midas web page development (more later).&lt;br /&gt;
** mhttpd: added hidding equipments option&lt;br /&gt;
**&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Automated_tests&amp;diff=3628</id>
		<title>Automated tests</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Automated_tests&amp;diff=3628"/>
		<updated>2026-09-29T16:04:30Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* BitBucket pipeline */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== make test ==&lt;br /&gt;
&lt;br /&gt;
After compiling midas with cmake, you can run an automated test script that will:&lt;br /&gt;
&lt;br /&gt;
* create a new midas experiment&lt;br /&gt;
* run a few programs and commands&lt;br /&gt;
* check that the output of the script matches what is expected.&lt;br /&gt;
&lt;br /&gt;
From the main midas directory (not your build directory!) run:&lt;br /&gt;
&lt;br /&gt;
 unset MIDAS_EXPT_NAME&lt;br /&gt;
 make test&lt;br /&gt;
&lt;br /&gt;
At the end of the tests you should see &lt;br /&gt;
&lt;br /&gt;
 MIDAS self test completed with no errors&lt;br /&gt;
&lt;br /&gt;
== Code coverage ==&lt;br /&gt;
&lt;br /&gt;
As of summer 2022, midas supports generating code coverage reports for the C++ code.&lt;br /&gt;
&lt;br /&gt;
=== Pre-requisites ===&lt;br /&gt;
&lt;br /&gt;
Install the lcov package from apt/yum/brew/macports depending on your OS preference.&lt;br /&gt;
&lt;br /&gt;
=== Compiling with support for code coverage ===&lt;br /&gt;
&lt;br /&gt;
Build midas with the &amp;quot;Coverage&amp;quot; build type, e.g. &lt;br /&gt;
&lt;br /&gt;
 mkdir build_cov&lt;br /&gt;
 cd build_cov&lt;br /&gt;
 cmake .. -DCMAKE_BUILD_TYPE=Coverage&lt;br /&gt;
 make install&lt;br /&gt;
&lt;br /&gt;
=== Generating coverage report ===&lt;br /&gt;
&lt;br /&gt;
From the main midas directory (not your build directory!) run:&lt;br /&gt;
&lt;br /&gt;
 unset MIDAS_EXPT_NAME&lt;br /&gt;
 make coverage&lt;br /&gt;
&lt;br /&gt;
This will generate HTML files with annotated source code coverage based on the same tests as &amp;lt;code&amp;gt;make test&amp;lt;/code&amp;gt;. It will also print an overall summary to screen.&lt;br /&gt;
&lt;br /&gt;
The starting point is ~14% code coverage in summer 2022 before any dedicated effort to increase the coverage.&lt;br /&gt;
&lt;br /&gt;
=== Reverting to the non-coverage build ===&lt;br /&gt;
&lt;br /&gt;
Note that the default build type for midas is &amp;lt;code&amp;gt;RelWithDebInfo&amp;lt;/code&amp;gt;. &amp;lt;b&amp;gt;The coverage build disables optimizations&amp;lt;/b&amp;gt; and enables code coverage instrumentation, so is only suitable for running the code coverage tests! &lt;br /&gt;
&lt;br /&gt;
To revert back to your normal build, do one of the following:&lt;br /&gt;
&lt;br /&gt;
If you compiled the coverage version in a &#039;&#039;separate build directory&#039;&#039; (e.g. build_cov), run:&lt;br /&gt;
&lt;br /&gt;
 cd build&lt;br /&gt;
 make install&lt;br /&gt;
&lt;br /&gt;
If you compiled the coverage version in your &#039;&#039;regular build directory&#039;&#039;, run:&lt;br /&gt;
&lt;br /&gt;
 cd build&lt;br /&gt;
 cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo&lt;br /&gt;
 make install&lt;br /&gt;
&lt;br /&gt;
== Gitlab pipeline ==&lt;br /&gt;
&lt;br /&gt;
Midas source code is hosted on Gitlab, and a CI/CD pipeline is configured to build on Ubuntu and run &amp;lt;code&amp;gt;make test&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The pipeline is scheduled to run against the develop branch weekly (not on every commit), but can also be triggered manually by developers using the [https://gitlab.triumf.ca/midas/midas/-/pipelines Gitlab pipelines page].&lt;/div&gt;</summary>
		<author><name>Dfujimoto</name></author>
	</entry>
	<entry>
		<id>https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3627</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://daq00.triumf.ca/MidasWiki/index.php?title=Main_Page&amp;diff=3627"/>
		<updated>2026-09-29T16:02:28Z</updated>

		<summary type="html">&lt;p&gt;Dfujimoto: /* News and Support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
MIDAS is a modern data acquisition system developed at [http://www.psi.ch PSI] and [http://www.triumf.ca TRIUMF]. Supported hardware includes VME, Fastbus, CAMAC, RS232, GPIB, USB, ethernet, fiber optic and MSCB attached data acquisition devices. MIDAS is written in C/C++ and runs on Linux, MacOS and MS Windows. It is licensed under the [http://www.gnu.org/copyleft/gpl.html GNU Public License].&lt;br /&gt;
[[Introduction|&#039;&#039;&#039;more...&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
= Documentation =&lt;br /&gt;
&lt;br /&gt;
* [[Midas documentation| Main Documentation]]&lt;br /&gt;
* [[Installation | Installation Instructions]]&lt;br /&gt;
* [[Changelog | Changelog / Upgrade Instructions]]&lt;br /&gt;
* [https://daq.triumf.ca/~daqweb/doc/midas-develop/html/modules.html &amp;lt;i&amp;gt;Doxygen&amp;lt;/i&amp;gt;] Code structure, functions, etc...&lt;br /&gt;
* [https://bitbucket.com/tmidas/midas git repository on bitbucket] Source code, bug tracking, etc&lt;br /&gt;
* [https://midas.triumf.ca/forum MIDAS forum] Discussion, announcements, problem reports, requests for improvements&lt;br /&gt;
* [https://dsdaqgw.triumf.ca/zensical MIDAS documentation] pre-production early access to new documentation&lt;br /&gt;
&lt;br /&gt;
= News and Support=&lt;br /&gt;
&lt;br /&gt;
For news about bug fixes and new releases, go to the&lt;br /&gt;
[https://midas.triumf.ca/forum MIDAS forum] hosted by TRIUMF using&lt;br /&gt;
the [http://elog.psi.ch/elog ELOG] system. Users can register in this system to be notified automatically via &lt;br /&gt;
E-mail when new entries are submitted.&lt;br /&gt;
&lt;br /&gt;
Another source of information is the [https://gitlab.triumf.ca/midas/midas Gitlab Repository] of MIDAS, where one can see the latest changes to the software.&lt;br /&gt;
&lt;br /&gt;
Finally, you can read presentations from&lt;br /&gt;
* [https://indico.psi.ch/conferenceDisplay.py?ovw=True&amp;amp;confId=3793 2015 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/428/ 2017 MIDAS Workshop]&lt;br /&gt;
* [https://meetings.triumf.ca/event/429/ 2019 MIDAS Workshop]&lt;br /&gt;
* [[2023 MIDAS Workshop]]&lt;br /&gt;
* [[2025 MIDAS Workshop]]&lt;br /&gt;
&lt;br /&gt;
= Related packages =&lt;br /&gt;
&lt;br /&gt;
* [http://elog.psi.ch/elog ELOG] - Electronics Logbook from PSI&lt;br /&gt;
* [https://bitbucket.org/tmidas/manalyzer/src/master/ manalyzer] - data analysis from TRIUMF&lt;br /&gt;
* [[ROOT]] - data analysis package from CERN&lt;br /&gt;
* [[ROOTANA]] - ROOT-based analyzer for MIDAS&lt;br /&gt;
* [[ROODY]] - viewer for online histograms&lt;br /&gt;
* http://elog.psi.ch/rome/ - MEG/PSI data analysis package&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=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>