Skip to content

Commit f7550f4

Browse files
Create install-production-server.md
1 parent 4b830f6 commit f7550f4

File tree

1 file changed

+299
-0
lines changed

1 file changed

+299
-0
lines changed

install-production-server.md

Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
## Description
2+
This page contains the instructions on how to install WISE on your production server. These specific instructions are for installing WISE onto an Ubuntu server, but WISE should work on other types of Linux servers too.
3+
4+
## Update Ubuntu
5+
```
6+
sudo apt update -y
7+
```
8+
```
9+
sudo apt upgrade -y
10+
```
11+
12+
## Install MySQL
13+
14+
```
15+
sudo apt install mysql-server -y
16+
```
17+
18+
Connect to mysql so you can run mysql commands.
19+
```
20+
sudo mysql
21+
```
22+
23+
While in mysql, run these commands. Make sure to replace replace-this-with-a-password-for-the-database and remember the password for later.
24+
```
25+
create database wise_database;
26+
CREATE USER 'wiseproduser'@'%' IDENTIFIED BY 'replace-this-with-a-password-for-the-database';
27+
GRANT ALL PRIVILEGES ON wise_database.* TO 'wiseproduser'@'%';
28+
FLUSH PRIVILEGES;
29+
```
30+
31+
## Install Redis
32+
33+
```
34+
sudo apt install redis-server -y
35+
```
36+
Open the redis.conf file for editing.
37+
```
38+
sudo vim /etc/redis/redis.conf
39+
```
40+
Inside the redis.conf file, change `supervised no` to `supervised systemd`
41+
42+
## Install Nginx
43+
44+
```
45+
sudo apt install nginx -y
46+
```
47+
48+
Run these commands to update /etc/nginx/nginx.conf settings.
49+
50+
```
51+
sed 's/http {/http {\n add_header ip $server_addr;/' -i /etc/nginx/nginx.conf
52+
sed 's/include \/etc\/nginx\/sites-enabled\/\*;/include \/etc\/nginx\/sites-enabled\/\*;\n\n ##\n # Browser preferred language detection \(does NOT require AcceptLanguageModule\)\n ##\n\n map \$http_accept_language \$accept_language {\n ~\*\^tr tr;\n ~\*\^es es;\n ~\*\^pt pt;\n ~\*\^ja ja;\n ~\*\^zh-Hans zh-Hans;\n ~\*\^zh-Hant zh-Hant;\n ~\*\^zh-CN zh-Hans;\n ~\*\^zh-TW zh-Hant;\n }/' -i /etc/nginx/nginx.conf
53+
sed 's/gzip on;/gzip on;\n gzip_types text\/plain text\/xml image\/gif image\/jpeg image\/png image\/svg+xml application\/json application\/javascript application\/x-javascript text\/javascript text\/css;/' -i /etc/nginx/nginx.conf
54+
sed 's/TLSv1 //g' -i /etc/nginx/nginx.conf
55+
sed 's/TLSv1.1 //g' -i /etc/nginx/nginx.conf
56+
```
57+
58+
Delete the default link in /etc/nginx/sites-enabled.
59+
```
60+
rm /etc/nginx/sites-enabled/default
61+
```
62+
63+
Create the file /etc/nginx/sites-enabled/wise.conf and put the contents below into it. Make sure to replace replace-with-website-address with your actual website address. This should be something like wise.berkeley.edu
64+
```
65+
upstream tomcat {
66+
server 127.0.0.1:8080 fail_timeout=0;
67+
}
68+
69+
server {
70+
listen 80;
71+
server_name replace-with-website-address;
72+
charset utf-8;
73+
access_log off;
74+
rewrite ^/wise5/(.*)$ /assets/wise5/$1 last;
75+
76+
location ~ ^/(curriculum|studentuploads) {
77+
root /opt/tomcat/webapps;
78+
try_files $uri $uri/ =404;
79+
}
80+
81+
location ~* ^/(admin|api|portal|projectIcons|websocket|teacher\/account\/info|teacher\/management|student\/account\/info|pages) {
82+
include proxy_params;
83+
proxy_pass http://tomcat;
84+
client_max_body_size 50M;
85+
proxy_set_header Upgrade $http_upgrade;
86+
proxy_set_header Connection "upgrade";
87+
proxy_set_header X-Forwarded-Proto https;
88+
}
89+
90+
if ($accept_language ~ "(es|ja|pt|tr|zh-Hant|zh-Hans)") {
91+
# Redirect "/" to Angular app in browser's preferred language
92+
rewrite ^/$ /$accept_language permanent;
93+
}
94+
95+
# Everything under the Angular app is always redirected to Angular in the correct language
96+
location ~ ^/(es|ja|pt|tr|zh-Hant|zh-Hans) {
97+
root /usr/share/nginx/html/wise-client;
98+
try_files $uri /$1/index.html?$args;
99+
}
100+
101+
location / {
102+
root /usr/share/nginx/html/wise-client/en-US;
103+
try_files $uri $uri/ /index.html;
104+
}
105+
}
106+
```
107+
108+
Create a wise-client folder.
109+
```
110+
mkdir /usr/share/nginx/html/wise-client
111+
```
112+
113+
On a web browser, go to the [WISE-Client releases page](https://github.com/WISE-Community/WISE-Client/releases).
114+
115+
Find the release version you want and scroll down to the "Assets" section and right click on the "English build" link (or any other language build) and choose "Copy link address". On your server, use wget to download the build file.
116+
```
117+
wget replace-with-link-to-client-build-file
118+
```
119+
120+
Move the client build file to the wise-client folder. For example if you downloaded the "English Build" which gave you the en-US.tar.gz file, you would do this.
121+
```
122+
mv en-US.tar.gz /usr/share/nginx/html/wise-client
123+
```
124+
125+
Unpack the build file.
126+
```
127+
cd /usr/share/nginx/html/wise-client
128+
tar -xzf en-US.tar.gz
129+
```
130+
131+
Restart Nginx.
132+
```
133+
systemctl restart nginx
134+
```
135+
136+
## Install Java
137+
138+
```
139+
sudo apt install openjdk-11-jdk-headless -y
140+
```
141+
142+
## Install Tomcat
143+
144+
Create Tomcat group.
145+
```
146+
groupadd -g 1001 tomcat
147+
```
148+
149+
Create tomcat user.
150+
```
151+
useradd -u 1001 -g tomcat -c "Apache Tomcat" -d $CATALINA_HOME -s /usr/sbin/nologin tomcat
152+
```
153+
154+
Add ubuntu user to tomcat group.
155+
```
156+
usermod -a -G tomcat ubuntu
157+
```
158+
159+
Create Tomcat directory.
160+
```
161+
mkdir /opt/tomcat
162+
```
163+
164+
Make tomcat user the owner of the tomcat directory.
165+
```
166+
chown tomcat:tomcat /opt/tomcat
167+
```
168+
169+
Download Tomcat 9.
170+
```
171+
wget -P /tmp https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.82/bin/apache-tomcat-9.0.82.tar.gz
172+
```
173+
174+
Unpack Tomcat 9.
175+
```
176+
tar xzvf /tmp/apache-tomcat-9.0.82.tar.gz -C /opt/tomcat --strip-components=1
177+
```
178+
179+
Give tomcat user ownership of the tomcat directory contents.
180+
```
181+
chown -R tomcat:tomcat /opt/tomcat
182+
```
183+
184+
Give tomcat user execute permission on tomcat bin folder.
185+
```
186+
chmod -R u+x /opt/tomcat/bin
187+
```
188+
189+
Create the Tomcat service file. Open the tomcat.service file for editing. Note this file does not exist yet.
190+
```
191+
sudo vim /etc/systemd/system/tomcat.service
192+
```
193+
194+
Paste the text below into the tomcat.service file.
195+
```
196+
[Unit]
197+
Description=Tomcat
198+
After=network.target
199+
200+
[Service]
201+
Type=forking
202+
203+
User=tomcat
204+
Group=tomcat
205+
206+
Environment="JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64"
207+
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom"
208+
Environment="CATALINA_BASE=/opt/tomcat"
209+
Environment="CATALINA_HOME=/opt/tomcat"
210+
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
211+
Environment="CATALINA_OPTS=-Xms512M -Xmx2048M -server -XX:+UseParallelGC"
212+
213+
ExecStart=/opt/tomcat/bin/startup.sh
214+
ExecStop=/opt/tomcat/bin/shutdown.sh
215+
216+
RestartSec=10
217+
Restart=always
218+
219+
[Install]
220+
WantedBy=multi-user.target
221+
```
222+
223+
Remove the default Tomcat ROOT folder.
224+
```
225+
rm -rf /opt/tomcat/webapps/ROOT
226+
```
227+
228+
Download wise.war. On a web browser, go to the [WISE-API releases page](https://github.com/WISE-Community/WISE-API/releases).
229+
230+
Find the release version you want and scroll down to the "Assets" section and right click on the "Build" link and choose "Copy link address". On your server, use wget to download the build file.
231+
```
232+
wget replace-with-link-to-api-build-file
233+
```
234+
235+
Rename wise.war to ROOT.war.
236+
```
237+
mv wise.war ROOT.war
238+
```
239+
240+
Move ROOT.war to the Tomcat webapps folder.
241+
```
242+
mv ROOT.war /opt/tomcat/webapps
243+
```
244+
245+
Add https to the Tomcat server.xml file.
246+
```
247+
sed 's/<Connector port="8080"/<Connector port="8080" scheme="https"/' -i $CATALINA_HOME/conf/server.xml
248+
```
249+
250+
Reload the daemon.
251+
```
252+
systemctl daemon-reload
253+
```
254+
255+
Start Tomcat.
256+
```
257+
systemctl start tomcat
258+
```
259+
260+
Enable Tomcat on startup.
261+
```
262+
systemctl enable tomcat
263+
```
264+
265+
Create Tomcat curriculum and studentuploads folders.
266+
```
267+
sudo -u tomcat -g tomcat mkdir /opt/tomcat/webapps/curriculum
268+
sudo -u tomcat -g tomcat mkdir /opt/tomcat/webapps/studentuploads
269+
```
270+
271+
Create application.properties.
272+
```
273+
cp /opt/tomcat/webapps/ROOT/WEB-INF/classes/application_sample.properties /opt/tomcat/webapps/ROOT/WEB-INF/classes/application.properties
274+
```
275+
276+
Look through application.properites and set/update values appropriately. In particular make sure you update the values below.
277+
* wise.hostname (this should be something like https\://wise.berkeley.edu)
278+
* wise4.hostname (this should be something like https\://wise.berkeley.edu/legacy)
279+
* curriculum_base_dir (this should be /opt/tomcat/webapps/curriculum)
280+
* project_icons_base_dir (this should be /opt/tomcat/webapps/ROOT/projectIcons)
281+
* studentuploads_base_dir (this should be /opt/tomcat/webapps/studentuploads)
282+
* spring.datasource.password (this should be the replace-this-with-a-password-for-the-database you created earlier)
283+
284+
If you want to receive emails when users fill out the contact form you will need to set these values
285+
* spring.mail.host
286+
* spring.mail.port
287+
* spring.mail.username
288+
* spring.mail.password
289+
* contact_email
290+
291+
If you want to allow users to log in with their Google account you will need to set these values
292+
* google.clientId
293+
* google.clientSecret
294+
* google.tokens.dir
295+
296+
Restart Tomcat.
297+
```
298+
systemctl restart tomcat
299+
```

0 commit comments

Comments
 (0)