Deployment procedure of Glass fish Server on Ubuntu


System Requirements

server requires the following dependencies to be installed.

1. Ubuntu 11.04 OS
2. Jdk 7
3. Mysql server 5.1.54
4. Glassfish Server version 3.1


Step 1: Login to the server

1.1 Remote login server by ‘SSH Secure Shell Client’

1.2 Login directly as root user
After logging into the server directly, open the terminal window.

Write following command sequentially in the terminal window.

JDK
1. sudo add-apt-repository --yes ppa:webupd8team/java
2. Write your root user password
3. sudo apt-get update
4. sudo apt-get install --yes oracle-java7-installer

MYSQL SERVER
5. sudo apt-get install --yes mysql-server
Glassfish
6. cd /root/
7. wget http://download.java.net/glassfish/3.1.2.2/release/glassfish-3.1.2.2.zip
8. unzip glassfish-3.1.2.2.zip


Step 2: Database

Requirements:
1. databasebackup.sql
2. Mysql server installed


3.1 Create a new Database
1. Open the terminal window

2. Type: MYSQL –uusername –ppassword;” (-uroot –ppassword123) to login to mysql server
3. Type: CREATE DATABASE databasebackup CHARACTER SET utf8 COLLATE utf8_general_ci;
4. Type: SHOW DATABASES; (to list the existing database and check if the new DB is there.)
5. Type: “exit” to logout from the mysql server

3.2 Restore the database
1. Upload the database backup file (i.e databasebackup.sql) to a location on the server.
2. Open the terminal window.
3. Goto the directory where the main changescript is uploaded
4. Type: MYSQL -uusername -ppassword “name of database” < databasebackup.sql
5. Type: MYSQL –uusername –ppassword; to login to mysql server
6. Type: USE databasebackup; to select the database
7. Type: SELECT * FROM table_name; (if the databasebackup.sql was successfully restored then this will display the table_name table information)



Step 3: How to start glassfish server
After you have unzipped the glassfish server successfully, go into the glassfish bin directory to start the server

Start or stop glassfish server.

1. Open the terminal window
2. Type: cd /root/glassfish3/bin/
This command will take you to the Glassfish installer directory.
3. Type: ./asadmin start-domain domain1
This command will start the Glassfish server.
4. Type: ./asadmin stop-domain domain1
This command will start the Glassfish server.


Step 4: How to deploy Server

Requirements:
1. server.war file
2. Glassfish server version 3.1
3. Mysql server installed
Please collect the latest server WAR file from the developer. If you have the latest war file, use the following steps to deploy the server. Please also ensure that the server database is setup before you proceed.

4.1 Deploy WAR File:
1. To check if the Glassfish server is up and running . Open a web browser and type the URL to access the the admin console for Glassfish. You will need to specify the port number as well (example 'http:// 192.168.1.105:4848') the default port number of glashfish3 is 4848.
2. Log into the Glasshfish admin panel (default username:password)
3. Click on ‘Application’ link from side bar
4. Click on ‘deploy’ button
5. Select the location radio button. If the server WAR file is located your local hard disk, select the first option. If it is on the server hard disk then select the second option.
6. Click on ‘Ok’ button
7. If the server is successfully deployed then you will see it in the applications panel


Step 5: How to setup the server storage directory

Requirements:
1. Newly installed server WAR file in glassfish server
2. The databasebackup.sql is running on a mysql server
Once the server is successfully deployed and configured to the correct database you will need to specify the image repository in glassfish and the mysql database. This is the directory where all the images will be stored.


5.1 Create the storage directory
1. Open the terminal window.
2. Type: MKDIR <foldername> (/imagedir)
3. Type: CD /imagedir (go inside the /imagedir and create the following subdirectories /abc, /def)
4. Type: MKDIR abc
5. Type: MKDIR def
6. Type: CHMOD 777 /imagedir (to apply the read write execute permission)

5.2 Setup repository path in Glassfish
The first step is to add the directory as a property in Glassfish Server
1. Open a browser and login to the glassfish admin console (https://192.168.1.105:4848)
2. Extend 'Server-config' in side menu bar (Configurations>server-config)
3. Extend in 'Virtual Service' (Configurations>server-config> virtual service)
4. Click on 'Server' (Configurations>server-config> virtual service> server)
5. Click the “Add Property” button in Additional Properties .
6. Enter name and values
7. Example name=”alternatedocroot_1”
8. Example value= “from=/ imagedir /* dir=/root/glassfish/”
9. Click on 'Save' button