PDA

View Full Version : virtual private server


sdl15
10-27-2004, 12:28 PM
I spent a lot more time setting up a host for Laszlo than I should have. I want to share my notes in the hope of easing the process for others. This mini-guide is for people (like me) who are not experts on Tomcat configuration and just want to make LPS work.

I choose WebIntellects for my Virtual Private Server. It has a good plan for only $60/month. These notes are best used with WebIntellects.

Step 0 - Prepare a Laszlo web application

First make sure you have a full web application ready to deploy. It is best to test this on your own computer. Here is what I did:

copy C:\Program Files\Laszlo Presentation Server 2.2\Server\lps-2.2

to a new directory, for example:

C:\Program Files\Laszlo Presentation Server 2.2\Server\main

Now remove everything from main that you really don't need, for example, I didn't need the following directories:
demos
docs
examples
laszlo-explorer
my-apps
tools

Be sure to keep the WEB-INF directory and the lps directory.

Put your application into main, starting with the index.html or index.jsp file in the main directory.

Now configure Tomcat to see your web app. Go to

C:\Program Files\Laszlo Presentation Server 2.2\Server\tomcat-5.0.24\conf\LPS\localhost

add a context file here (e.g. main.xml) and put the following XML in it:

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="../../main" path="/main">
</Context>

Now restart (or run) laszlo server (i.e. Tomcat), wait for it to fully start and then point your web browser to:

http://localhost:8080/main/

Your application should now appear. If not, debug until it does, no point on going on if not.

Step 1 - Get a virtual server

If the application is working, then you are ready to deploy on a virtual server. My example is written to fit WebIntellects:

http://www.webintellects.com/solutions/virtualvpsplans.htm

but some points may apply to other servers.

Select at least plan 2, as Tomcat is not part of plan 1. $60/month.

Wait for emails from WebIntellects about your logins and nameservers and such. When you get the emails try to login to the server (as root) using SSH and try to login to Plesk. If both of these work then you are ready to proceed to the next step.

Step 2 - Setup the domain

In Plesk click on Clients link. Select 'Add New Client Account'. Remember your login and password that you enter here - these are used for the FTP.

Finish creating the account and then select 'Add New Domain'. Enter your domain name (you don't actualy have to own the domain at this time, but doing this does not register that domain so you need to do that part).

Now you should come to edit the domain and in here you will see a icon for Tomcat. Ignore it, this is not a very good way to manage Tomcat. I spent many hours messing with that tool so use it at your own risk.

Step 3 - Upload the application

Zip up the application, including all subdirectories, for example I zipped everything in main:

C:\Program Files\Laszlo Presentation Server 2.2\Server\main

FTP this file up to the server using the account name and password you created in step 1. Put the file in the tmp directory.

From now on you need to use the command line. For the command line (SSH - for example use Putty from http://www.chiark.greenend.org.uk/~sgtatham/putty/)

Step 4 - Activate Tomcat manager (optional)

I like the Tomcat manager, if you want to try it use the command line.

Change to the configuration directory:

[root@admin /]# cd /etc/tomcat4/

Edit the tomcat-users file:

[root@admin tomcat4]# vi tomcat-users.xml

Add a user with manager role:

<user username="aaaaa" password="bbbbb" roles="manager"/>

Login to Tomcat manager just to see it work (where domain.name is your domain name or ip):

http://domain.name:8080/manager/html

Step 5 - Setup the web application

You may choose to put your application almost anywhere, but I choose /var/lib/tomcat4/

[root@admin /]# cd /var/lib/tomcat4/

This is what you should see:

[root@admin tomcat4]# ll
total 4
drwxr-xr-x 5 root root 1024 Oct 17 11:00 common
drwxr-xr-x 5 root root 1024 Oct 17 11:00 server
drwxr-xr-x 4 root root 1024 Oct 17 11:00 shared
drwxrwx--- 7 root tomcat4 1024 Oct 27 06:52 webapps

Unzip and set permissions for your web app (where domain.name is your domain name):

[root@admin tomcat4]# unzip /home/httpd/vhosts/domain.name/tmp/main.zip -d main
[root@admin tomcat4]# chgrp tomcat4 -R main
[root@admin tomcat4]# chown tomcat4 -R main
[root@admin tomcat4]# chmod 776 -R main

Check that permissions are set:

[root@admin tomcat4]# ll
total 9943
drwxr-xr-x 5 root root 1024 Oct 17 11:00 common
drwxrwx--- 6 tomcat4 tomcat4 1024 Oct 27 09:22 main
drwxr-xr-x 5 root root 1024 Oct 17 11:00 server
drwxr-xr-x 4 root root 1024 Oct 17 11:00 shared
drwxrwx--- 7 root tomcat4 1024 Oct 27 06:52 webapps

Add the context to server.xml

[root@admin /]# cd /etc/tomcat4/
[root@admin tomcat4]# vi server.xml

look for line 553 or so, it should have ROOT on it:

<!--
<Context path="" docBase="ROOT" debug="0"/>
-->

Now add a line right after that:

<Context docBase="/var/lib/tomcat4/main" path="/main" />

Grant permissions to lps to write to the log and cache folders. To grant I did the following, but there may be other ways:

[root@admin /]# cd /etc/tomcat4/
[root@admin tomcat4]# vi catalina.policy

at bottom of policy file add:

// LPS permission
grant codeBase "file:/var/lib/tomcat4/main/WEB-INF/lib/-"{
permission java.security.AllPermission;
};

Now exit the command line.

Step 6 - Restart the server.

In Plesk, click the Virtuozzo link. Now select 'Start/Stop VPS' and finally 'Reboot VPS'. Wait a few minutes.

Step 7 - Verify install

Use Tomcat manager to verify the context is installed:

http://domain.name:8080/manager/html

Visit the web application directly:

http://domain.name:8080/main/

Check the logs. Use command line again:

[root@admin /]# cd /var/log/tomcat4/

Display today's log (i.e. change the log file name to use the correct date).

[root@admin tomcat4]# tail -20 localhost_log.2004-10-27.txt
2004-10-27 12:17:46 jsp: init
2004-10-27 12:17:46 LPS: init
2004-10-27 12:17:47 LPS: LPS_HOME is /var/lib/tomcat4/main
2004-10-27 12:17:47 LPS: LPS config directory is: /var/lib/tomcat4/main/WEB-INF/lps/config
2004-10-27 12:17:47 LPS: Detailed LPS log is at /var/lib/tomcat4/main/WEB-INF/lps/work/logs/lps.log
2004-10-27 12:17:47 LPS: LPS log configured with /var/lib/tomcat4/main/WEB-INF/lps/config/lps.xml
2004-10-27 12:17:47 LPS: ------------------------------------
2004-10-27 12:17:47 LPS: Laszlo Presentation Server, 2.2, initialized
2004-10-27 12:17:47 LPS: Running in context:Apache Tomcat/4.1
2004-10-27 12:17:47 LPS: Build: lps-2.2-001144-0001
2004-10-27 12:17:47 LPS: Built on: 08:36 PM 04-Oct-2004
2004-10-27 12:17:47 LPS: Running against JRE 1.4.2_04
2004-10-27 12:17:47 LPS: Running with Java CLASSPATH: /usr/lib/jvm/java/lib/tools.jar:/usr/share/tomcat4/bin/bootstrap.jar
2004-10-27 12:17:47 LPS: Running on Linux 2.4.20-021stab022.5.777-enterprise
2004-10-27 12:17:47 LPS: Running as user tomcat4
2004-10-27 12:17:47 LPS: Max memory: 63.56 MB
2004-10-27 12:17:47 LPS: Total memory: 19.87 MB
2004-10-27 12:17:47 LPS: Available memory: 6.38 MB

If the application appears to be running and if the log looks good then all is probably well.