Intro

I don’t know why I keep forgetting how to prepare development environment from scratch. Whenever I want to start new project, I always re-searching how to do it. So I guess it’s better to leave some trace here.

Recently, I’ve been studying about Java Web Programming with its framework. To be specific, the framework is Spring framework. Creating a web app and deploy it to the real server is always be my objective. So, I will leave a note how to prepare the development environment first before starting the web app programming.

Platform Used

You can choose any technology to used. Following platform and framework is just my preferences.

  • Cloud Server: Google Cloud Platform (cloud.google.com)
  • Web Server: Tomcat Apache 7
  • Database: MariaDB
  • IDE: Eclipse
  • SVN: Gitlab
  • Programming Language: Java
  • Spring Framework: SpringBoot, Thymeleaf

I thought preparing the environment was easy, but its not. It also needs time to implement everything. In real project, usually this job desk is dedicated to one person.

Preparing Cloud Server

You have to create account for Google Cloud Platform at the beginning. It is free for 1 year usage. In the beginning, you will be given a sort of money. If you can manage your resource usage well, then it will ended up FREE. However, if you need more resources than expected, you might need to make extra payment. If your purpose is only for self-study, don’t worry! You can use it for FREE.

  1. Register for an account
  2. Go to Console
  3. Create new project
  4. Create VM Instance
  5. Choose Machine Type, OS, etc (explained below)
  6. Done

In the VM Instance dialog page, you have to choose the server you want to use or buy. The blue highlight is the one that I recommended and I think it is enough for studying. Remember that we have limited credit for paying the server. So choose it wisely.

Machine Type:

  • Micro 0.6GB RAM $4.28
  • Small 1.7GB RAM $14.20
  • 1vCPU 3.75GB RAM $24.67
  • 2vCPU 7.5GB RAM $48.95

OS Type:

  • Debian 9
  • CentOS 6,7
    (I chose CentOS 7)
  • Ubuntu 14-18
  • Windows Server
  • etc

Note: When I planned to install Gitlab platform in the same server, the small 1.7GB RAM server is insufficient. You have to upgrade the memory at least 2GB, means you have to choose the 3.75GB one. That is why I use the Gitlab server for SVN, and create project there, OR another option was using light version SVN. Refer to this link for installation.

For Firewall option, check Allow HTTP and HTTPS traffic.

Once a server instance is created. Your server will be assigned a public IP. VOILA~ you have own server now!

Accessing through SSH Client

There is several way to access your server. Since you are the owner of GCP account, you can access it using SSH web client from GCP. However, multiple connection is not allowed. If you are working in a team, it is better to prepare SSH connection so that your team can access the server using SSH client, such as Putty. This is what you have to do:

  • Generate Private Key using PuttyGen app, must be installed separately
  • Click Generate to create your private key
  • Draw anything in the blank space to generate the key
  • After the key is generated, change the Key Comment field with any username
  • Fill Key passphrase as password of your username
  • Click “Save private key”
  • Your key will be saved as .ppk file

Register Private Key to GCP

After generated, you have to register your private key to Google Cloud Server. This is how:

  • Open GCP Console
  • In the left navigation menu, click Metadata
  • Click the SSH Key tab
  • Click Edit
  • Click Add Item
  • Copy paste the RSA code from PuttyGen. The one that start with “ssh-rsa…..”. The name will be automatically generated according to the Key comment you’ve input
  • Save

Setting up SSH Client Putty

If you work on Windows, Putty is the most common tool to use. Last time when I used Mac, I access it through GCP Web console, because I cannot find a good replacement for Putty #failed T.T

  • Upload your private key here -> Category: Connection -> SSH -> Auth
  • Check only this: Attempt Keyboard-Interactive SSH2 , Allow agent forwarding, Display pre-authentication banner. This is to prevent future issue when another person using the same key to login.
  • Back to Session menu. Fill IP address with your IP server address
  • Click Open
  • When the SSH windows prompted, fill your passphrase to enter the terminal

Changing Root Password

Just in case, giving root access a password is recommended for safety. To set or change a new password, type following:

> sudo passwd

To enter root mode, type su in the terminal.

Installing Web Server Tomcat

The newest version currently is Tomcat 9. You can install it manually, and I did it too. It took some time to install, because you have to configure everything manually. And usually, you will find a lot of error that let you keep googling for the solution haha So, in short, I chose to install Tomcat 7 instead via Yum haha. 1 minute and done.

Tomcat 7 Installation Command Line

> sudo yum install tomcat
> sudo yum install tomcat-webapps tomcat-admin-webapps
> sudo vi /usr/share/tomcat/conf/tomcat-users.xml

Add following:

   <tomcat-users>

        <user username=”username” password=”passwd”  roles=”manager-gui, admin-gui”/

   </tomcat-users>

> sudo systemctl start tomcat
> sudo systemctl enable tomcat

Go to your browser and type your server IP address like this: http://xxx.xxx.xxx.xxx:8080

You should see Tomcat homepage right now~

To Be Continued…