Wiki source code of Deploying on Ubuntu 24.04
Last modified by D Tim Cummings on 2024/07/16 07:07
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | These are the steps used to set up a WebObjects deployment environment on Ubuntu 24.04 with Java 21. It does not install WebObjects or any frameworks because it is assumed they are bundled with any apps you deploy. Change the environment variables in the first step if you want different install location or different user that will run the WebObjects applications. Regardless, you will have to at least change SERVER_NAME and SERVER_IP which are only examples and ones you would never use in practice. | ||
2 | |||
3 | == Set environment variables for your configuration to be used in following scripts == | ||
4 | |||
5 | For example | ||
6 | |||
7 | {{code}} | ||
8 | export SERVER_NAME=woserver.example.com | ||
9 | export SERVER_IP=172.5.4.3 | ||
10 | export WEBOBJECTS_GROUP=webobjects | ||
11 | export WEBOBJECTS_USER=webobjects | ||
12 | export NEXT_ROOT=/opt/webobjects | ||
13 | export URL_PART=apps | ||
14 | {{/code}} | ||
15 | |||
16 | The default behaviour is for URL_PART to be "cgi-bin". I prefer to use "apps" in my WebObjects URLs. | ||
17 | |||
18 | == Install Java 21 == | ||
19 | |||
20 | {{code}} | ||
21 | sudo apt install openjdk-21-jdk-headless | ||
22 | {{/code}} | ||
23 | |||
24 | At time of writing this was build 21.0.3+9-Ubuntu-1ubuntu1. | ||
25 | |||
26 | == Add user and group == | ||
27 | |||
28 | {{code}} | ||
29 | sudo groupadd $WEBOBJECTS_GROUP | ||
30 | sudo useradd -m -g $WEBOBJECTS_GROUP -s /bin/bash $WEBOBJECTS_USER | ||
31 | echo -e "export NEXT_ROOT=$NEXT_ROOT" | sudo tee /home/$WEBOBJECTS_USER/.bash_profile | ||
32 | {{/code}} | ||
33 | |||
34 | (% id="HCreatedirectories" class="auto-cursor-target" %) | ||
35 | == Create directories == | ||
36 | |||
37 | {{code}} | ||
38 | sudo mkdir -p /var/log/webobjects | ||
39 | sudo mkdir -p /etc/WebObjects/wotaskd | ||
40 | sudo mkdir -p /etc/WebObjects/JavaMonitor | ||
41 | {{/code}} | ||
42 | |||
43 | == Create configuration files == | ||
44 | |||
45 | {{code}} | ||
46 | cat <<EOF | sudo tee /etc/default/webobjects | ||
47 | WEBOBJECTS_GROUP=$WEBOBJECTS_GROUP | ||
48 | WEBOBJECTS_USER=$WEBOBJECTS_USER | ||
49 | NEXT_ROOT=$NEXT_ROOT | ||
50 | JAVA_MONITOR_ARGS="-WOPort 56789" | ||
51 | WEBOBJECTS_URL= | ||
52 | EOF | ||
53 | |||
54 | cat <<EOF | sudo tee /etc/WebObjects/Properties | ||
55 | er.extensions.WOHostUtilities.localhostips=($SERVER_IP) | ||
56 | WOHost=$SERVER_IP | ||
57 | EOF | ||
58 | |||
59 | echo -e "WOHost=$SERVER_IP" | sudo tee /etc/WebObjects/wotaskd | ||
60 | echo -e "WOHost=$SERVER_IP" | sudo tee /etc/WebObjects/JavaMonitor | ||
61 | {{/code}} | ||
62 | |||
63 | (% id="HSetpermissions" class="auto-cursor-target" %) | ||
64 | == Set permissions == | ||
65 | |||
66 | {{code}} | ||
67 | sudo chown -R $WEBOBJECTS_USER:$WEBOBJECTS_GROUP /var/log/webobjects | ||
68 | sudo chown -R $WEBOBJECTS_USER:$WEBOBJECTS_GROUP /etc/WebObjects | ||
69 | {{/code}} | ||
70 | |||
71 | (% id="HInstallwotaskdandjavamonitorfromprojectwonder" class="auto-cursor-target" %) | ||
72 | == Install wotaskd and javamonitor from project wonder == | ||
73 | |||
74 | {{code}} | ||
75 | sudo mkdir -p $NEXT_ROOT/Local/Library/WebObjects/Applications | ||
76 | sudo mkdir -p $NEXT_ROOT/Local/Library/WebObjects/JavaApplications | ||
77 | cd $NEXT_ROOT/Local/Library/WebObjects/JavaApplications | ||
78 | |||
79 | sudo wget https://jenkins.wocommunity.org/job/Wonder7/lastSuccessfulBuild/artifact/Root/Roots/wotaskd.tar.gz | ||
80 | sudo tar zpxf wotaskd.tar.gz | ||
81 | sudo rm wotaskd.tar.gz | ||
82 | |||
83 | sudo wget https://jenkins.wocommunity.org/job/Wonder7/lastSuccessfulBuild/artifact/Root/Roots/JavaMonitor.tar.gz | ||
84 | sudo tar zpxf JavaMonitor.tar.gz | ||
85 | sudo rm JavaMonitor.tar.gz | ||
86 | |||
87 | sudo chown -R $WEBOBJECTS_USER:$WEBOBJECTS_GROUP $NEXT_ROOT/Local | ||
88 | sudo mkdir -p $NEXT_ROOT/bin | ||
89 | cd $NEXT_ROOT/bin | ||
90 | sudo ln -s $NEXT_ROOT/Local/Library/WebObjects/JavaApplications/wotaskd.woa/wotaskd | ||
91 | sudo ln -s $NEXT_ROOT/Local/Library/WebObjects/JavaApplications/JavaMonitor.woa/JavaMonitor javamonitor | ||
92 | |||
93 | # Fix wotaskd and javamonitor to work with Java 17 if not already | ||
94 | sudo sed -i '2s/= $/= --add-exports=java.base\/sun.security.action=ALL-UNNAMED/' $NEXT_ROOT/Local/Library/WebObjects/JavaApplications/wotaskd.woa/Contents/UNIX/UNIXClassPath.txt | ||
95 | sudo sed -i '2s/= $/= --add-exports=java.base\/sun.security.action=ALL-UNNAMED/' $NEXT_ROOT/Local/Library/WebObjects/JavaApplications/javamonitor.woa/Contents/UNIX/UNIXClassPath.txt | ||
96 | {{/code}} | ||
97 | |||
98 | (% id="HCreateservicesforwotaskdandjavamonitor" class="auto-cursor-target" %) | ||
99 | == Create services for wotaskd and javamonitor == | ||
100 | |||
101 | {{code}} | ||
102 | cat <<EOF | sudo tee /lib/systemd/system/wotaskd.service | ||
103 | [Unit] | ||
104 | Description=WebObjects/Wonder wotaskd | ||
105 | Documentation=https://wiki.wocommunity.org/display/documentation/Wonder+JavaMonitor+and+wotaskd | ||
106 | AssertPathExists=/var/log/webobjects | ||
107 | AssertPathExists=$NEXT_ROOT/Local/Library/WebObjects/JavaApplications/wotaskd.woa | ||
108 | After=network.target | ||
109 | [Service] | ||
110 | User=$WEBOBJECTS_USER | ||
111 | Group=$WEBOBJECTS_GROUP | ||
112 | Environment=NEXT_ROOT=$NEXT_ROOT | ||
113 | Environment="JVM_OPTIONS=-Xms32m -Xmx64m -XX:NewSize=2m" | ||
114 | ExecStart=$NEXT_ROOT/Local/Library/WebObjects/JavaApplications/wotaskd.woa/wotaskd -WOPort 1085 -Xms32m -Xmx64m >> /var/log/webobjects/wotaskd.log 2>&1 | ||
115 | Restart=on-failure | ||
116 | RestartSec=5 | ||
117 | [Install] | ||
118 | WantedBy=multi-user.target | ||
119 | EOF | ||
120 | |||
121 | cat <<EOF | sudo tee /lib/systemd/system/javamonitor.service | ||
122 | [Unit] | ||
123 | Description=WebObjects/Wonder JavaMonitor | ||
124 | Documentation=https://wiki.wocommunity.org/display/documentation/Wonder+JavaMonitor+and+wotaskd | ||
125 | AssertPathExists=/var/log/webobjects | ||
126 | AssertPathExists=$NEXT_ROOT/Local/Library/WebObjects/JavaApplications/JavaMonitor.woa | ||
127 | After=wotaskd.service | ||
128 | [Service] | ||
129 | User=$WEBOBJECTS_USER | ||
130 | Group=$WEBOBJECTS_GROUP | ||
131 | Environment=NEXT_ROOT=$NEXT_ROOT | ||
132 | Environment="JVM_OPTIONS=-Xms32m -Xmx64m -XX:NewSize=2m" | ||
133 | ExecStart=$NEXT_ROOT/Local/Library/WebObjects/JavaApplications/JavaMonitor.woa/JavaMonitor -WOPort 56789 -Xms32m -Xmx64m >> /var/log/webobjects/javamonitor.log 2>&1 | ||
134 | Restart=on-failure | ||
135 | RestartSec=5 | ||
136 | [Install] | ||
137 | WantedBy=multi-user.target | ||
138 | EOF | ||
139 | |||
140 | sudo systemctl daemon-reload | ||
141 | |||
142 | sudo systemctl enable wotaskd | ||
143 | sudo systemctl start wotaskd | ||
144 | sudo systemctl status wotaskd | ||
145 | |||
146 | sudo systemctl start javamonitor | ||
147 | sudo systemctl status javamonitor | ||
148 | {{/code}} | ||
149 | |||
150 | (% id="HInstallApacheHTTPServer28MPMprefork29" class="auto-cursor-target" %) | ||
151 | == Install Apache HTTP Server (MPM prefork) == | ||
152 | |||
153 | {{code}} | ||
154 | sudo apt install apache2 make apache2-dev -y | ||
155 | sudo a2dismod mpm_event | ||
156 | sudo a2enmod mpm_prefork | ||
157 | sudo a2enmod expires | ||
158 | sudo a2enmod ssl | ||
159 | sudo a2enmod rewrite | ||
160 | |||
161 | # Add ServerName to conf to avoid configtest errors | ||
162 | echo "ServerName $SERVER_NAME" | sudo tee /etc/apache2/conf-available/server-name.conf | ||
163 | sudo a2enconf server-name | ||
164 | |||
165 | # Install WebObjects adaptor | ||
166 | git clone https://github.com/wocommunity/wonder.git | ||
167 | cd wonder/Utilities/Adaptors | ||
168 | sed -i '107s/CGI Apache2.2/Apache2.4/' make.config | ||
169 | sed -i '9s/MACOS/LINUX/' make.config | ||
170 | make | ||
171 | cd Apache2.4 | ||
172 | sudo apxs -i -a -n WebObjects mod_WebObjects.la | ||
173 | sudo cp apache.conf /etc/apache2/mods-available/WebObjects.conf | ||
174 | sudo sed -i "7s/^LoadModule/# LoadModule/" /etc/apache2/mods-available/WebObjects.conf | ||
175 | sudo sed -i "15,18s/cgi-bin/$URL_PART/" /etc/apache2/mods-available/WebObjects.conf | ||
176 | sudo sed -i "38s/localhost/$SERVER_IP/" /etc/apache2/mods-available/WebObjects.conf | ||
177 | sudo a2enmod WebObjects | ||
178 | |||
179 | # Create Apache virtual host | ||
180 | sudo mkdir -p /var/www/$SERVER_NAME | ||
181 | sudo mkdir -p $NEXT_ROOT/Local/Library/WebServer/Documents/WebObjects | ||
182 | sudo ln -s $NEXT_ROOT/Local/Library/WebServer/Documents/WebObjects /var/www/$SERVER_NAME/WebObjects | ||
183 | |||
184 | cat <<EOF | sudo tee /etc/apache2/sites-available/$SERVER_NAME.conf | ||
185 | <VirtualHost *:80> | ||
186 | ServerName $SERVER_NAME | ||
187 | DocumentRoot /var/www/$SERVER_NAME | ||
188 | <Directory /> | ||
189 | Require all denied | ||
190 | </Directory> | ||
191 | <Directory /var/www/$SERVER_NAME/> | ||
192 | Options Indexes FollowSymLinks MultiViews | ||
193 | AllowOverride None | ||
194 | Require all granted | ||
195 | </Directory> | ||
196 | <IfModule mod_expires.c> | ||
197 | ExpiresActive On | ||
198 | ExpiresByType text/html "access 5 minutes" | ||
199 | </IfModule> | ||
200 | ErrorLog ${APACHE_LOG_DIR}/error_apps_$SERVER_NAME.log | ||
201 | CustomLog ${APACHE_LOG_DIR}/access_apps_$SERVER_NAME.log combined | ||
202 | </VirtualHost> | ||
203 | EOF | ||
204 | |||
205 | sudo a2ensite $SERVER_NAME.conf | ||
206 | |||
207 | sudo apachectl configtest | ||
208 | sudo systemctl restart apache2 | ||
209 | {{/code}} | ||
210 | |||
211 | (% id="HTroubleshooting" class="auto-cursor-target" %) | ||
212 | == Troubleshooting == | ||
213 | |||
214 | {{code}} | ||
215 | # To test WOAdaptorInfo edit /etc/apache2/mods-available/WebObjects.conf and uncomment | ||
216 | WebObjectsAdminUsername public | ||
217 | |||
218 | #restart apache2 | ||
219 | sudo systemctl restart apache2 | ||
220 | |||
221 | #check in browser | ||
222 | http://woserver.example.com/apps/WebObjects/WOAdaptorInfo | ||
223 | |||
224 | #to turn on woadaptor logging | ||
225 | touch /tmp/logWebObjects | ||
226 | |||
227 | #might need to mkdir for adaptor logging | ||
228 | mkdir /Library | ||
229 | chown $WEBOBJECTS_USER:$WEBOBJECTS_GROUP /Library | ||
230 | {{/code}} |