Instructions for Setting Up Apache Tomcat 11.0.7 Alongside Nginx and SSL on Rocky Linux Version 9
Apache Tomcat 11.0.7, combined with Nginx and SSL, provides a modern, secure, and scalable environment for Java web applications on Rocky Linux 9. Here's an outline of the process for setting up this stack:
- Install Java OpenJDK Apache Tomcat requires a Java Runtime Environment. Install OpenJDK 11 on Rocky Linux 9: This installs the Java Development Kit needed for Tomcat.
- Download and Install Apache Tomcat 11.0.7
- Download the Tomcat 11.0.7 tar.gz archive from the official Apache site or trusted mirrors.
- Extract it to a suitable directory, for example .
- Adjust ownership to a dedicated user if preferred for increased security.
- Configure Tomcat
- Customize if needed to change ports or other settings.
- Run Tomcat for the first time to verify installation:
- Verify access via Tomcat default port 8080.
- Install and Configure Nginx as a Reverse Proxy
- Install Nginx:
- Configure Nginx to listen on port 80 (HTTP) and proxy requests to Tomcat’s port 8080. Example config snippet for : ```nginx server { listen 80; server_name your-domain.com;location / { proxy_pass http://localhost:8080/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } ```
- Set Up SSL with Let’s Encrypt (Certbot)
- Install Certbot and its Nginx plugin:
- Obtain and install SSL certificates for your domain:
- Certbot will automatically configure Nginx to use HTTPS and redirect HTTP traffic to HTTPS.
- Ensure Firewall Allows HTTP, HTTPS, and Tomcat's port 8080 Run:
- Start and Enable Services Enable Nginx and Tomcat (using systemd service files, create one for Tomcat if needed) to start on boot: ```bash sudo systemctl enable nginx sudo systemctl start nginx
# For Tomcat, create and enable systemd service: sudo nano /etc/systemd/system/tomcat.service bash sudo systemctl daemon-reload sudo systemctl enable tomcat sudo systemctl start tomcat ```
This setup ensures that web traffic is secured via HTTPS at Nginx and proxied efficiently to Tomcat backend. For further customization or troubleshooting, logs for Nginx () and Tomcat () offer diagnostic insights.
For deploying Apache Tomcat 11.0.7, you can create an instance on Shape.Host by visiting our website, clicking "Create", choosing "Instance", selecting your desired server location, choosing Rocky Linux 9 (64-bit) as the operating system, and picking a plan with at least 2 CPUs, 4 GB RAM, and 20 GB SSD.
- To prioritize sustainability in the industry, incorporate renewable-energy sources for the power requirements of the Tomcat environment, utilizing energy-efficient data-and-cloud-computing technologies.
- Implementing finance strategies that invest in the renewable-energy sector can help reduce carbon emissions in the technology industry and ensure a stable and eco-friendly energy supply for Java web applications.
- Leverage advanced technology solutions to monitor and analyze energy usage patterns within the Tomcat industry, which can lead to better resource management, cost optimization, and a greener IT footprint.