Giter Club home page Giter Club logo

nllds's Introduction

NLLDS

Data System for NeuroLang Lab

Environment

Java SE 1.8

PHP >= 7.4

Mysql 5.7.42

Tomcat 8.5

elFinder 2.1.65

Limesurvey 6.5.1

INSTALLATION

  1. Prepare Server Environment ( Java & PHP & Mysql & Tomcat)
# Install Java 8: 
sudo apt-get install openjdk-8-jdk
java -version

# Install Tomcat 8.5.x:
Download tomcat 8.5.x from https://tomcat.apache.org/download-80.cgi
tar -zxvf apach-tomcat-8.5.x.tar.gz
cd apach-tomcat-8.5.x/bin
sudo ./catalina.sh start
Access http://localhost:8080 from browser

# Install mysql 5.7.x on ubuntu (>=20.04):
sudo vim /etc/apt/sources.list.d/mysql.list
# Add the following:
deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-apt-config
deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7
deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-tools
deb-src http://repo.mysql.com/apt/ubuntu/ bionic mysql-5.7
# apt update
sudo apt update
# May have errors, replace the public_key and run the following
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <public_key>
# run again
sudo apt update
# check if mysql-5.7 exists
sudo apt-cache policy mysql-server
# Installation
sudo apt install mysql-client=5.7.x-1ubuntu18.04
sudo apt install mysql-server=5.7.x-1ubuntu18.04
# Validation
mysql --version
# Config mysql
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY 'your_password';
# allow remote access
adjust etc/mysql/mysql.conf.d/mysqld.cnf to set bind-address = 0.0.0.0 (original 127.0.0.1)
grant all on *.* to admin@'%' identified by 'your_password' with grant option;
flush privileges;

#Install PHP >= 7.4: 
sudo apt install php7.4-cgi, php7.4-mysql, php7.4-xml, php7.4-mbstring
  1. Prepare FTPS(SSL/TLS) Server (openssl + vsftpd) (The local file system is used, so you can ignore this step temporarily.)
# Vsftpd installation
sudo apt update
sudo apt install vsftpd
sudo systemctl start vsftpd
sudo systemctl enable vsftpd
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
sudo nano /etc/vsftpd.conf
	ssl_enable=YES
	allow_anon_ssl=NO
	force_local_data_ssl=YES
	force_local_logins_ssl=YES
	ssl_tlsv1=YES
	ssl_sslv2=NO
	ssl_sslv3=NO
	rsa_cert_file=/etc/ssl/private/vsftpd.pem
	rsa_private_key_file=/etc/ssl/private/vsftpd.pem
sudo service vsftpd restart

# Better close the firewall, nor the ftp may not be accessed
sudo ufw disable

# Linux User Group Setting:
groupadd nllds
useradd -d /home/ftpmanger -m ftpmanger -g nllds
passwd ftpmanger

# Set ftp users only can access specific dir
sudo nano /etc/vsftpd.conf
	chroot_local_user=YES
	user_config_dir=/etc/vsftpd_user_list/
	allow_writeable_chroot=YES
sudo mkdir /etc/vsftpd_user_list/
sudo nano /etc/vsftpd_user_list/ftpmanger
	local_root=/media/bmi/BigData/NLL_Project
	write_enable=YES
sudo service vsftpd restart
  1. Adjust src/main/resources/*.xml files to connect to Mysql

  2. Execute NLLDS.sql

  3. Build the project and export war package

  4. Upload war package to server(tomcat/webapps)

# Add this to server.xml in tomcat/conf
<Context path="/NLLDS" docBase="/home/wyd/apache-tomcat-8.5.x/webapps/NLLDS.war" debug="0" reloadable="true" />
# And change port 8080 to 80
<Connector port="80"> 
  1. Copy JavaBridge.jar, script-api.jar, php-servlet.jar, php-script.jar to Tomcat/lib folder

  2. Adjust tomcat/conf/web.xml

Add the following in node <web-app>:
<listener>
<listener-class>php.java.servlet.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>PhpJavaServlet</servlet-name>
<servlet-class>php.java.servlet.PhpJavaServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>PhpCGIServlet</servlet-name>
<servlet-class>php.java.servlet.fastcgi.FastCGIServlet</servlet-class>
<init-param>
<param-name>prefer_system_php_exec</param-name>
<param-value>On</param-value>
</init-param>
<init-param>
<param-name>php_include_java</param-name>
<param-value>Off</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>PhpJavaServlet</servlet-name>
<url-pattern>*.phpjavabridge</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>PhpCGIServlet</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>

Add the following in node <welcome-file-list>:
<welcome-file>index.php</welcome-file>
  1. Upload elFinder to Tomcat/webapps and adjust the config under php/connector.minimal.php

  2. Connect to Department Storage Server (Extra Step)

# Install necessary packages
sudo apt-get install smbclient
sudo apt install cifs-utils

# create mount dir
sudo mkdir /mnt/nll

# Mount test
smbclient //xxx.xxx.xxx.xxx/xxx -U <username>

# Add persistent mount entries (//xxx.xxx.xxx.xxx/xxx /mnt/nll cifs username=xxxxxx,password=xxxxxx,vers=3.1.1,rw,user,auto,_netdev,iocharset=utf8 0 0) to the end of the `/etc/fstab` file
sudo vim /etc/fstab

# Make sure the File Path in elFinder's php/connector.minimal.php refer to the mount path
  1. Set Tomcat start automatically at boot
# create new system service
sudo vi /etc/systemd/system/tomcat.service
# Add the following content to tomcat.service:
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target

[Service]
Type=forking

Environment=JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
Environment=CATALINA_PID=/home/bmi/NLLDS/apache-tomcat-8.5.99/temp/tomcat.pid
Environment=CATALINA_HOME=/home/bmi/NLLDS/apache-tomcat-8.5.99
Environment=CATALINA_BASE=/home/bmi/NLLDS/apache-tomcat-8.5.99
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'
Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'
ExecStart=/home/bmi/NLLDS/apache-tomcat-8.5.99/bin/startup.sh
ExecStop=/home/bmi/NLLDS/apache-tomcat-8.5.99/bin/shutdown.sh

User=root
Group=root
UMask=0007
RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target
# reload system service
sudo systemctl daemon-reload

# enable start at boot
sudo systemctl enable tomcat

# start service
sudo systemctl start tomcat

# check service status
sudo systemctl status tomcat
  1. Install LimeSurvey
Download limesurvey6.x.x from https://community.limesurvey.org/downloads/ and unzip
Upload limesurvey to Tomcat/webapps (Use Binary to transfer)
Replace the login.php page
chmod -R 777 /path/to/limesurvey/tmp
chmod -R 777 /path/to/limesurvey/upload
chmod -R 777 /path/to/limesurvey/application/config
Set /etc/php/cgi/php.ini `short_open_tag` to `ON`
Restart Tomcat and view http://localhost/limesurvey to install limesurvey
# Adjust /conf/server.xml under apach-tomcat by adding this two attributes to <Connector> node:
relaxedQueryChars="[]|{}-^&#x60;&quot;&lt;&gt;"
relaxedPathChars="[]|{}-^&#x60;&quot;&lt;&gt;"
  1. Replace the favicon.ico under tomcat/webapps/ROOT

  2. Disable automatic updates for Java, Tomcat, Mysql, and PHP

# search the package need to hold
dpkg --get-selections | grep -i jdk
dpkg --get-selections | grep -i tomcat
dpkg --get-selections | grep -i mysql
dpkg --get-selections | grep -i php

# hold the package
sudo apt-mark hold <package>

# show the holded package
sudo apt-mark showhold
  1. Restart tomcat and ready now.

Backup

Databse backup

# install corn
sudo apt install cron

# create backup script (use root)
sudo nano NLLDS_backup.sh

# Add following content:

#!/bin/bash
USER="XXX"
PASSWORD="XXX"
DATABASE="XXX"
BACKUP_DIR="/path/to/mysql_backup"
DATE=$(date +%F)
BACKUP_FILE="$BACKUP_DIR/XXX_$DATE.sql"
mysqldump -u$USER -p$PASSWORD $DATABASE > $BACKUP_FILE
cp "$BACKUP_FILE" /path/to/storage/

# set execute permission
chmod +x NLLDS_backup.sh

# schedule task
sudo crontab -e

# add following (backup 2:00 AM every day)
0 2 * * * /bin/bash NLLDS_backup.sh

File backup

# install rsync
sudo apt-get install rsync

# schedule task
sudo crontab -e

# add following (backup 4:00 AM every Sunday)
0 4 * * 0 rsync -a /path/to/A/ /path/to/B/

Updates

Due to function iteration, the following files under src/main/webapp/WEB-INF/views are temporarily ineffective:

  • projectquestionnaire.jsp
  • questionnaire.jsp
  • subjectask.jsp
  • subjectquestionnaire.jsp
  • taskfields.jsp
  • tasklist.jsp

nllds's People

Contributors

witten-wu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.