Build a Java Prod environment on Ubuntu
If you need to setup a java test or production environment, We have prepared a bootstrap document for you. We will setup Java8, Tomcat server, MySQL database and nginx as reverse proxy. This document is handy to setup a new environment on cloud services like AWS or Digital Ocean.
Following setup is prepared on Ubuntu 14.
Nginx
Nginx is one of the most popular web servers. You can use it as a web serve or reverse proxy. We will use it as reverse proxy in front of tomcat. You can setup nginx from this document.
Java8
Java8 setup is easy. Run following commands and you are done. Here is the reference document.
1 2 3 |
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer |
MySQL
You can use this document to setup mysql. Follow all instructions for safe installation. There are important steps for security, make sure that you run security script.
Tomcat 8
You can follow this document for tomcat. When you get installation package, make sure that you get latest from tomcat offical page. Don’t forget to complete user instruction at the end of the document. You need to put your war into /webapps directory of tomcat. You need to give write access to this directory.
1 |
sudo chown -R tomcat webapps/ |
If you need to pass environment varaibles like spring profile, you need to pass this information with setenv.sh file under /bin directory of tomcat. If you don’t have this file, create yourself. Here is a sample config.
1 |
JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=prod" |