Apache Linux Installation Steps

Add User and Group

 $ groupadd tomcat

  $ useradd -s /sbin/nologin -g tomcat -d /path/to/tomcat tomcat

  $ passwd tomcat

Extract the package

tar xvzf apache-tomcat-[#].tar.gz
mv apache-tomcat-[#] /desiredpath/tomcat

Once the tomcat user is created, give it permissions and ownership rights to the Tomcat installation directory and all of its contents using the following chown command
# chown -R tomcat:tomcat /desiredpath/tomcat
# ls -l /desiredpath/tomcat

create a tomcat.service



vi /etc/systemd/system/tomcat.service

Copy and paste the following configuration in the tomcat.service file.

[Unit]
Description=Apache Tomcat Server
After=syslog.target network.target

[Service]
Type=forking
User=tomcat
Group=tomcat

Environment=CATALINA_PID=/desiredpath/tomcat/temp/tomcat.pid
Environment=CATALINA_HOME=/desiredpath/tomcat
Environment=CATALINA_BASE=/desiredpath/tomcat
ExecStart=/usr/local/tomcat9/bin/catalina.sh start ExecStop=/usr/local/tomcat9/bin/catalina.sh stop RestartSec=10 Restart=always [Install] WantedBy=multi-user.target
systemctl daemon-reload
# systemctl start tomcat.service
# systemctl enable tomcat.service
# systemctl status tomcat.service

Setup JAVA_HOME if required. Most like the path will be /etc/alternatives/java


If fails verify the tomcat.service file throughly

Enable Remote Access to Tomcat Manager and Host Manager


To enable remote access to the Manager app, open and edit the configuration file /opt/apache-tomcat-9.0.24/webapps/host-manager/META-INF/context.xml.


# vi /usr/local/tomcat9/webapps/manager/META-INF/context.xml

Then look for the following line.

allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

change it to this to allow tomcat access from IP address * from any host or network.

allow=".*" />

Similarly, enable remote access to the Host Manager app in the file /usr/local/tomcat9/webapps/host-manager/META-INF/context.xml as shown above.

Relay Traffic For Non-Root Tomcat User

When running Tomcat as a user other than the root user, you will not be able to bind to port 80, which is where Tomcat listens for HTTP requests.  To get around this, you can use Netfilter, which is packaged with all major Linux distributions:

    
  # iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080

  # iptables -t nat -I OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 8080

 iptables-save

Sometimes, the service may not start because of the permissions on /desirectpath/tomcat/bin directory files

Switch to root user and give 777 on all the files in bin directory

Reboot the server. It should automatically bring up the tomcat web server.
If not, run systemctl start tomcat.service


 Apache Linux Basic Configuration Steps

Edit the /conf/tomcat-users.xml file carefully.
Uncomment the users section and add the roles.

Example:
<role rolename="admin"/>
<role rolename="manager-status"/>
<role rolename="manager-gui"/>
  <user username="admin" password="Winter123" roles="manager-gui"/>
  <user username="manager" password="Winter123" roles="manager-status,admin-gui"/>
  <user username="robot" password="Winter123" roles="manager-script"/>


  <role rolename="tomcat"/>
  <role rolename="role1"/>
  <user username="tomcat" password="Winter123" roles="tomcat,manager-gui,admin-gui"/>
  <user username="both" password="Winter123" roles="tomcat,role1"/>
  <user username="role1" password="Winter123" roles="role1"/>



That is it I know.




Comments

Popular posts from this blog

Dolibarr Installation

MySQL Installation on Linux