Site Tools


opentele2:developer:serversetup:ubuntudesktop1404

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

opentele2:developer:serversetup:ubuntudesktop1404 [2017/04/25 21:19]
mike Added "REFERENCES" to the list of commands the server needs for using the database (I'm not sure if this is due to updates to OpenTele, Grails or mysql, but it currently seems to be needed when setting up a system)
opentele2:developer:serversetup:ubuntudesktop1404 [2018/12/12 13:34]
Line 1: Line 1:
- 
- 
- 
-====== Setting up an Ubuntu desktop as development server ====== 
- 
-In order to run the OpenTele servers on a tomcat server with a MYSQL database on an Ubuntu 14.04 (LTS) desktop machine, you can follow these steps. ​ (The following assumes that you have completed the steps needed to build the software from [[opentele2:​developer:​buildinstructions|the build instructions]]) on the same machine as you wish to run OpenTele from. 
- 
-===== Install MySQL and Tomcat ===== 
- 
-Fist install the LAMP stack (Apache, MySQL and PHP).  We only really need MySQL at this point, but phpmyadmin is great for browsing the database, and it requires PHP and Apache, which can also be used for other cool stuff). 
-<code bash> 
-...$ sudo apt-get install lamp-server^ 
-. 
-. 
-. 
-...$ 
-</​code>​ 
- 
-**Note the ^ after lamp-server,​ it's not a typo.** 
- 
-During the install you will be asked to select a root password for the MySQL server, remember that password, you will need it later. 
- 
-Then install Tomcat. 
-<code bash> 
-...$ sudo apt-get install tomcat7 
-. 
-. 
-. 
-...$ 
-</​code>​ 
- 
-Optionally install phpmyadmin: 
- 
-<code bash> 
-...$ sudo apt-get install phpmyadmin 
-. 
-. [Use the root password you created when installing LAMP when phpmyadmin asks you for master password to db, choose a new password for the phpmyadmin password] 
-. [Select the apache2 server when asked if it should configure a web server - selecting it means there need to be a [*] mark next to it] 
-. [When asked if phpmyadmin should use dbconfig-common to configure the database, answer <Yes> unless you have reasons not to] 
-. 
-...$ 
-</​code>​ 
- 
-//**Note:** When installing phpmyadmin, you will be asked some multiple choice questions, you make selection with the <SPACE BAR>, be careful not to misinterpret the cursor as the selection mark (which is a '​*'​ sign).// 
-===== Create OpenTele user for database ===== 
- 
-In order for OpenTele to use the database we need to create a user OpenTele can use to access the database. ​ First of all you need to get to the MySQL prompt 
- 
-<code bash> 
-...$ mysql -u root -p 
-Enter password: [Enter the password you choose when installing LAMP] 
-Welcome to the MySQL monitor. ​ Commands end with ; or \g. 
-. 
-. 
-. 
-</​code>​ 
- 
-//Notice: In our sandbox, the password is "​sandbox"​ // 
- 
-Now you need to create a database OpenTele can use 
-<code sql> 
-mysql> create database opentele character set utf8; 
-Query OK, 1 row affected (0.00 sec) 
- 
-mysql> GRANT SELECT, INSERT, UPDATE, CREATE, DELETE, DROP, ALTER, INDEX, REFERENCES on opentele.* TO '​username'​@'​localhost'​ IDENTIFIED BY '​password'; ​ 
-Query OK, 0 row affected (0.00 sec) 
- 
-mysql> flush privileges; 
-Query OK, 0 row affected (0.00 sec) 
- 
-mysql> quit 
-Bye 
-...$ 
- 
-</​code>​ 
- 
-Replace '​username'/'​password'​ in the above with your own username/​password combination. 
- 
-===== Create configuration files for OpenTele ===== 
- 
-This section is for versions of code from Feb 2016 and later. 
-For versions from before December 2015, please follow this  
-[[opentele2:​developer:​serversetup:​old|link]] 
- 
-While some configurations are and others can be build into the source code for the project, some configurations are most convenient made in a configuration file - the default is that they reside in the home folder (on Linux) for the user that was used to build OpenTele. 
- 
-The configuration files are stored in a folder with the name '​.opentele'​ in the root folder of the user that runs the server. ​ When running in Tomcat on Ubuntu that folder is : '/​usr/​share/​tomcat7/'​ (you can see a complete list of possible places for the file in the opentele2-server project (default place is: "​.../​OpenTele/​opentele-server/​grails-app/​conf/​Config.groovy",​ search for "​grails.config.locations"​). 
- 
-Create an '​.opentele'​ folder. 
- 
-<code bash> 
-...:~$ cd /​usr/​share/​tomcat7 
-...:/​usr/​share/​tomcat7$ sudo mkdir .opentele 
-...:/​usr/​share/​tomcat7$ cd .opentele 
-...:/​usr/​share/​tomcat7/​.opentele$ 
-</​code>​ 
- 
-In this folder create a file '​clinician.properties'​ with the following content: 
- 
-<​code>​ 
-# Common settings 
-dataSource.pooled = true 
-dataSource.logSql = true 
- 
-## MYSQL DB 
-dataSource.dialect = org.opentele.server.core.util.MySQLInnoDBDialect 
-dataSource.driverClassName = com.mysql.jdbc.Driver 
-dataSource.username = username 
-dataSource.password = password 
-dataSource.url = jdbc:​mysql://​localhost:​3306/​opentele 
-</​code>​ 
- 
-Replace the username/​password with the username/​password you selected when creating the database. 
- 
-Now create an identical file and save it under the name '​citizen.properties'​ (still in the '/​usr/​share/​tomcat7/​.opentele'​ folder). 
- 
-<​code>​ 
-# Common settings 
-dataSource.pooled = true 
-dataSource.logSql = true 
- 
-## MYSQL DB 
-dataSource.dialect = org.opentele.server.core.util.MySQLInnoDBDialect 
-dataSource.driverClassName = com.mysql.jdbc.Driver 
-dataSource.username = username 
-dataSource.password = password 
-dataSource.url = jdbc:​mysql://​localhost:​3306/​opentele 
-</​code>​ 
- 
-Again, replace the username/​password,​ with the ones you specified when creating the database (this is NOT the root password you created when installing the database). 
- 
-//There are two servers, one for clinicians, and one for citizens, they both use the same database as seen above, they don't share configuration files.// 
- 
-After cloning the repository, creating the above configuration files and creating a war-file, the server will reset the database each time the server is powered on. This allows the server to create the initial database, that is necessary to use both clinician and citizen server. However, if you need the data on the server to persist, when the server is turned off, a few changes are needed in the code. 
- 
-In the opentele2-server folder cloned from the github repository, open the file “opentele2-server / grails-app / conf / Config.groovy”. 
- 
-Under the item: “db_development” change the lines: 
- 
-<​code>​ 
-grails.plugin.databasemigration.dropOnStart = true 
-grails.plugin.databasemigration.updateOnStart = true 
-</​code>​ 
- 
-with  
- 
-<​code>​ 
-grails.plugin.databasemigration.dropOnStart = false 
-grails.plugin.databasemigration.updateOnStart = false 
-</​code>​ 
- 
-Afterwards, create a new war file and place it in Tomcat'​s webapps directory. 
- 
-===== Configure tomcat ===== 
- 
-OpenTele is a complex project that takes a significant amount of resources, due to this tomcat needs to have the memory available for applications increased. 
- 
-Create or open /​usr/​share/​tomcat7/​bin/​setenv.sh,​ you  
-might need to use sudo in order to be able to save your changes: 
- 
-<code bash> 
-...$ sudo nano /​usr/​share/​tomcat7/​bin/​setenv.sh 
-. 
-. 
-. 
-...$ 
-</​code>​ 
- 
-Add the following line to the file: 
- 
-<code bash> 
-CATALINA_OPTS="​$CATALINA_OPTS -Xms1024m -Xmx2048m -XX:​PermSize=256m -XX:​MaxPermSize=356m"​ 
-</​code>​ 
- 
-This will ensure the webapps can get between 1 GB and 2 GB of memory. 
- 
-Remember to ensure that your computer has 2 GB of ram otherwise this will fail. 
- 
-In order for tomcat to use the file, we need to make it executable: 
- 
-<code bash> 
-...$ sudo chmod a+x /​usr/​share/​tomcat7/​bin/​setenv.sh 
-</​code>​ 
- 
-Now create another file '​log4j.properties'​ in '/​var/​lib/​tomcat7/​lib/'​ with the following content (create the folder if it doesn'​t exists): 
- 
-<​code>​ 
- ​log4j.rootLogger=WARN,​ CA                                                          ​ 
- ​log4j.appender.CA=org.apache.log4j.ConsoleAppender ​                                 ​ 
- ​log4j.appender.CA.layout=org.apache.log4j.PatternLayout ​                             
- ​log4j.appender.CA.layout.ConversionPattern=%d{MMM dd, yyyy hh:mm:ss aa} %c%n%p: %m%n 
-</​code>​ 
- 
- 
-Restart tomcat to load the new settings: 
- 
-<code bash> 
-...$ sudo service tomcat7 restart 
-</​code>​ 
- 
-<del> 
-For reasons the writer of this text don't understand the permissions to the tomcat folder needs to be changed with the following command, if you want to run both the clinician and citizen servers in the same installation,​ they each run fine alone without changing the permissions:​ 
- 
-//This was probably related to a configuration issue where the H2 db was used.// 
-</​del>​ 
- 
-<code bash> 
-...$ # cd /​var/​lib/​tomcat7 
-...$ # sudo chmod -R a+rw * 
-...$ 
-</​code> ​ 
- 
-===== Start servers in tomcat ===== 
- 
-We are now ready to move the .war files we created in the build process to tomcat so we can access them from a web browser. 
- 
-Start by copying the opentele-server.war into the tomcat webapps folder. 
- 
-//Adjust path/folder names to your local configuration//​ 
- 
-<code bash> 
-...$ sudo cp ~/​OpenTele2/​opentele2-server/​target/​opentele-server.war /​var/​lib/​tomcat7/​webapps/​ 
-...$ 
-</​code>​ 
- 
-After copying the file to the webapps folder, tomcat will automatically unpack and launch it, you can follow the progress by monitoring '/​var/​lib/​tomcat7/​logs/​catalina.out'​. 
- 
-When the opentele server has started and have created the database (you will know when you can access http:/​127.0.0.1:​8080/​opentele-server) you should update '​datamon-config.properties',​ commenting out the '​create'​ line and commenting in the '​update'​ line - if you don't do this, then you can get into trouble the next time you start your system. 
- 
-After the file has been updated, you can copy the other servers into tomcat. 
- 
-<code bash> 
-...$ sudo cp ~/​OpenTele2/​opentele2-citizen-server/​target/​opentele-citizen-server.war /​var/​lib/​tomcat7/​webapps 
-...$ sudo cp ~/​OpenTele2/​opentele2-client-html/​dist/​dev/​opentele-client-html.war /​var/​lib/​tomcat7/​webapps 
-...$ 
-</​code>​ 
- 
  
opentele2/developer/serversetup/ubuntudesktop1404.txt · Last modified: 2018/12/12 13:34 (external edit)