Id like to use tomcat (user) to startup tomcat server. Not root. Can you help figure out where i am going wrong?
$su -p -s /bin/sh tomcat $CATALINA_HOME/bin/startup.sh
--Detailed question --
I have a question about setting up Tomcat 7 on ubuntu server. In short, I am unable to start tomcat server using my user (user: tomcat; group: tomcat). I am able to get it started and showing the default welcome page using root. I posted similar on unbuntu forum. hope that is ok.
I would like assistance understanding how to get tomcat server running with the correct user.
Here is some basic information.
My capabilities: I am new to Linux; taken one intro course. I can navigate around ok...I will research commands or switches if I dont understand one you've recommended. I may ask why a specific switch is used in a situation.
My objective: I want to run JSP pages on tomcat 7; and learn to secure the web server.
My goal is to convert over to JSP from visual basic. I've been learning Java, Java Servlets over the past year and half. I've always used tomcat, glassfish embedded in Eclipse and Netbeans. I would like to completely setup tomcat server so i can replicate on a virtual server provided by a web hosting company.
My computer is running: Ubuntu Server, with Linux 2.6.38-13-server x86_64
ubuntu 11.04 server
Probably too much information: - I have installed from CD, no server options selected (ftp, dns, samba, lamp, etc).
- Updated repository: apt-get update
- Upgraded files: apt-get upgrade
- Upgraded Distribution: apt-get dist-upgrade
- Added sysstat, enabled system activity reporting (SAR)
- Added nmap
- Downloaded and installed openjdk-6-jre and openjdk-6-jdk
Tomcat Download: Retrieved tomcat 7 from apache.hoxt.com
Extracted files and set in permanent location: $tar xzvf apache-tomcat-7.0.23.tar.gz
$sudo mv apache-tomcat-7.0.23 /var/lib/tomcat
Set environment variables (I chose in /etc/environment): $sudo vi /etc/environment
Created tomcat group & user and changed ownership of Tomcat directory $groupadd tomcat
$useradd -g tomcat -s /sbin/nologin -m -d /home/tomcat tomcat
$chown -R tomcat.tomcat /var/lib/tomcat
When running this command, there is no output to terminal. I also checked the catalina.out log file and it is still blank. So i do not understand why no response. I thought i would see an error message at terminal output if command or any parameters are wrong.
Now if i run the command below using sudo, it starts up and i see the start up log entries recorded in catalina.out
$sudo sh startup.sh
Using CATALINA_BASE: /var/lib/tomcat
Using CATALINA_HOME: /var/lib/tomcat
Using CATALINA_TMPDIR: /var/lib/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/lib/tomcat/bin/bootstrap.jar:/var/lib/tomcat/bin/tomcat-juli.jar
And tomcat welcome page is working.
My question again: Do you have advice on how to use tomcat user to start Tomcat 7 server?
Normally I set up an init script to start/stop Tomcat. Among other things, this means that I can ensure that if the server is restarted, Tomcat will also restart. You can use the "su" command and specify the Tomcat userID on the start and stop command handlers in the script.
One thing that can bite. If you start Tomcat under the root user ID, then attempt to run it later under its own ID, the root version of Tomcat will have written log, temp, and work files out under the root user's filesystem permissions, which can keep them from being updated by the Tomcat running under its own user ID. So it's good to make sure that these files have all been cleaned out before running the Tomcat server under its own ID.
An IDE is no substitute for an Intelligent Developer.
Joined: Dec 14, 2011
I will research how to implement a startup script. Thanks for your help. Gregg