Thursday, 13 February 2014

apt-get install debian PT2 (Tomcat 7)

No post for two months and now two post in a day, sometime life if strange.
Until yesterday I cannot be able to install properly Apache Tomcat 7 service and configure it on eclipse environment. Today I've do it almost easily, just to point out the concept that life is strange. 

First of all: you need to put your user into the sudoer list by typing in a terminal the following line: sudo adduser <username> sudo

Then you must log off and again log in.
Now your user have the super user grant when you call the sudo command.

But we are here to talk about install and configure tomcat7.

You must download the tar.gz from the official website , then extract it in one directory at your choice, i choose the standard download directory in my /home/.
Then from the command line move the whole directory in the /usr/lib directory using sudo mv /path/To/apache-tomcat-7 /usr/lib

To start and stop the service now run respectively these two command in terminal: 



  • Start: sudo /usr/lib/apache-tomcat-7.0.50/bin/startup.sh
  • Stop: sudo /usr/lib/apache-tomcat-7.0.50/bin/shutdown.sh
With this method there isn't a single shell script to restart the service, you must instead manually stop and re-start with this two script or, if you are able to do it, write one script by yourself.

At this point if you type http://localhost:8080 on your browser you can see the landing page of tomcat.



Now you need to configure the admin user of the manager-pages of your server.
Open the file /usr/lib/<apache-tomcat dir>/conf/tomcat-users.xml and inside the tag <tomcat-user> put the following line:


<role rolename="manager-gui"/>
<user username="<your user>" password="<your password>" roles="manager-gui,admin-gui"/>

Stop and restart the service, and access the manager app after typing your credential when needed.



From here you can easily deploy your project without using the file manager other than manage session and project.

Configuring Tomcat as server of Eclipse:

You have just install Tomcat in the way that I described above. Now you want to use it on eclipse, right?
Nothing most simple: 
You must go to Windows->preferences->server->Runtime Environment and add your Tomcat server.
Once you have add the server you can try a simple JSP page to test it.

If you do it, remember to stop the tomcat from a terminal window, or eclipse do not take it well and cry like a little girl.


Arrived here you probably ask why I don't install Tomcat from repository.
The answer is simple: apt-get install tomcat7 allows you to use the useful commands service tomcat7 start/restart/stop but divide the tomcat directory in a lot of places, so eclipse can retrieve some of the file that he need to use the server. 
There is a lot of tutorial for fix this problem, but to me no one seems working.


In the next post I'll explain how to install and configure MySql dbms.
Ygy Freezone



No comments:

Post a Comment