Probably not once after creating Web application you would like to put it on a remote server. Personally, I like to use for this services of openshift (httpss://www.openshift.com) in the case of the free version it allows registrations of 3 projects and supports such containers as Tomcat, Jboss or WildFly and there is no problem to hook up a database. For larger projects there is a paid version of these services. Unfortunately the service may at first seem quite complicated but in this may help present tutorial.
At the beginning we enter page openshift.com and create our account. Then we create a new project and select the type of application in my case it will be a Tomcat 7. We’ll get a new panel with such options
Public URL name for the address of our application. Openshift default gives us the domain baseconection. The name can be changed later in the options but we will have to re-create the project. For this tutorial is https://openshifttutorial-baseconnection.rhcloud.com
Source Code: We can provide the address of the repository on github personally I omitted it
Gears: small Resources for our aplication, we can select only small
Cartridges: Tomcat 7 (JBoss EWS 2.0) Selected aplication Container
Scaling: No scaling. If we select scaling on greater load openshift should use other free gears to handle our server
Region: aws-us-east-1 Region of our server. In free version it is actually the only option without limits
Click create aplication. Creation of the project may take a minute or two. The next window we can ignore. When you create the first applications openshift we need to give our SSH key to be able to connect to the server. This is best done by using tools provided by openshift. To do this, install the following applications if you don’t have them:
Ruby – https://rubyinstaller.org
Git – httpss://git-for-windows.github.io
Personally, I tested everything in Ruby Installer 2.0.0-p648 and is the recommended version but later versions should also work. For github choose the latest version of mine is 2.8.3
Install both tools and add environment variables to our path. Turn on the console command cmd and check if everything works with the following commands
ruby -v
git --version
After entering commands we should get the versions of installed ruby and git software. At the end install gem in charge of cooperation with openshift console. So lets enter command
gem install rhc
It remains only to generate our SSH code. Type in console
rhc setup
At the beginning we get this query:
enter the server hostname |openshift.redhat.com|
click simply enter
You’ll be asked for your login and password:
login – mail podany przy rejestracji
hasło – hasło podane przy rejestracji
The next question is
generate a token now?
answer yes. We just created our own ssh key
another question is about its the upload
"Your public ssh key must be uploaded to the OpenShift server to access code. Upload now?"
we answer also yes
Świetnie już możemy komunikować się z naszym kontem oraz aplikacjami. Wejdźmy do stworzonego przez nasz projektu dodajmy bazę danych klikając na add mysql 5.5 oraz postgressql 9.2 Zauważmy też adres kodu źródłowego po prawej stronie przyda on się nam w kolejnych krokach.
Great we now can communicate with our applications. Leave console. Let’s go to the created project and add database by clicking on the add MySQL 5.5 and PostgreSQL 9.2 Notice also address the source code on the right side it useful to us in the next steps.
We already have a ready applications on the server, but it would be good to be able to easily send to it our source code and test its operation. In my case, the IDE used for this type of action is Eclipse so I will show you how we can integrate our applications with it.
Turn on Eclipse and go to tab help -> Eclipse marketplace
In the search bar enter jboss tools, and select the appropriate tool for your version.
Go ahead and choose the modules JBoss OpenShift2 Tools and JBoss OpenShift3 Tools
Click next, our tools should be installed, restart Eclipse. Then we can create Openshift projects. Select File -> New -> Project We should have a new folder called Openshift and in it OpenShift Application.
Select it. You will be taken to the wizard for application. Select server type Openshift2 and fill in username and password. Give the informations provided during registration.
In the next window we can create a new project or download an existing one from server. As in the earlier stages we created our project lets download it. Select use my existing Openshift aplication and click browse. There, we choose our project.
Nasz projekt zostanie ściągnięty a my możemy już wysyłać nasz kod na serwer. W tym celu klikamy prawym przyciskiem na projekt i wybieramy team. Mamy tam standardowe funkcje jakie znajdziemy przy repozytoriach kodu. Jeśli pracujemy samemu i chcemy wysłać jedynie nasze aktualizacje na serwer wybieramy commit.
Our project will be downloaded and we can send our code on the server. To do this, right click on the project and select team tab. There we have the standard features that we can find in the code repositorys. If you are working alone and we only send our updates to the server, select commit.
Warto w tym miejscu jeszcze włączyć możliwość pobierania logów z serwera w szczególności że nie jest to trudne. Wybieramy zakładkę servers. Następnie klikamy prawym przyciskiem na nasz serwer openshifta. Wybieramy zakładkę openshift a tam klikamy na tail file. W nowym oknie możemy ustalić ile ostatnich logów pobieramy z serwera.
At this point it would be a good idea to turn on the ability to download logs from the server. Especially that it is not difficult. Select the tab servers. Then right click on openshift server. Select the tab openshift and there click on the tail file. In the new window, we can determine how many last logs should be downloaded from the server.
The last thing that would be good to configure is SFTP connection. To do this lets use FileZilla and Putty key generator
Sciągamy więc i instalujemy putty key generator. Gdy go uruchomimy wybieramy zakładkę conversion i klikamy na opcje import key. Teraz musimy wskazać nasz adres naszego klucza. Pamiętacie jeszcze jak w konsoli tworzyliśmy ten klucz odpowiadając na pytanie generate a token now? yes. Domyślnie klucz ten powinien znajdować się folderze C:\Users\{User Name}\.ssh i nazywał się id_rsa. Wybieramy go a następnie klikamy na Save private key zapisujemy go pod nazwą id_rsa.ppk To wszystko do czego przyda nam się Putty.
So we are downloading and instaling putty key generator. Run it and select conversion tab, then click Options and key import. Now we must indicate location of our key. Do you still remember how we created it after answering the question “generate a token now? yes”. By default openshift should save this key in the folder C:\Users\{User Name}\.Ssh and called it id_rsa. Go to this place and select it. Lastly click on Save private key save it under the name id_rsa.ppk That’s all we can close Putty generator.
Now we start FileZilla. Select Edit -> Setting. Enter the tab SFTP and click add key File. Select the newly generated file id_rsa.ppk
When it is done select File-> Site manager and choose new site
In windows, enter:
Host: openshifttutorial-baseconnection.rhcloud.com
Protocol: SFTP
Login Type: Normal
User: 57598d422d52710cab0000f1
Password: the password provided during registration
The user name is an ssh url which we can find on the application website. It is created by removing the ‘ssh://’ at the beginning and by removing everything after the monkey sign inclusive. If you do not remember host address it is also written there:
ssh://57598d422d52710cab0000f1@openshifttutorial-baseconnection.rhcloud.com/~/git/openshifttutorial.git/
Already after the first stage our application should be able to read as below
https://openshifttutorial-baseconnection.rhcloud.com
Openshift is a good platform to store projects such as these:
https://pan-towarzysz.rhcloud.com
https://gwiezdny-towarzysz.rhcloud.com