1. Install jdk7
//Check if jdk has been installed [root@iZwz9catu2mrq92b07d1d0Z ~]# yum list installed | grep javajava-1.7.0-openjdk.x86_64java-1.7.0-openjdk-demo.x86_64java-1.7.0-openjdk-devel.x86_64java-1.7.0-openjdk-devel.x86_64java-1.7.0-openjdk-javadoc.noarchjava-1.7.0-openjdk-src.x86_64tzdata-java.noarch 2017c-1.el6 @updates //Uninstall the existing jdk[root@iZwz9catu2mrq92b07d1d0Z ~]# yum -y remove java-1.7.0*//View the Java installation package in the yum library [root@iZwz9catu2mrq92b07d1d0Z ~]# yum -C list java*...java-1.7.0-openjdk.x86_64 1:1.7.0.151-2.6.11.0.el6_9 updatesjava-1.7.0-openjdk-devel.x86_64 1:1.7.0.151-2.6.11.0.el6_9 updatesjava-1.7.0-openjdk-devel.x86_64 1:1.7.0.151-2.6.11.0.el6_9 updatesjava-1.7.0-openjdk-devel.x86_64 1:1.7.0.151-2.6.11.0.el6_9 updatesjava-1.7.0-openjdk-javadoc.noarch 1:1.7.0.151-2.6.11.0.el6_9 updates...//Install jdk7[root@iZwz9catu2mrq92b07d1d0Z ~]# yum -y install java-1.7.0*//Install successfully[root@iZwz9catu2mrq92b07d1d0Z ~]# java -versionjava version "1.7.0_151" OpenJDK Runtime Environment (rhel-2.6.11.0.el6_9-x86_64 u151-b00) OpenJDK 64-Bit Server VM (build 24.151-b00, mixed mode)
2. Install tomcat7
//Download tomcat7[cjh@iZwz9catu2mrq92b07d1d0Z ~]$ wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.82/bin/apache-tomcat-7.0.82.tar.gz//Che check the compressed package file [cjh@iZwz9catu2mrq92b07d1d0Z ~]$ tar -ztvf apache-tomcat-7.0.82.tar.gz//Decompress [cjh@iZwz9catu2mrq92b07d1d0Z ~]$ tar -zxvf apache-tomcat-7.0.82.tar.gz[cjh@iZwz9catu2mrq92b07d1d0Z ~]$ lsapache-tomcat-7.0.82 apache-tomcat-7.0.82.tar.gz
Note: When we try to start tomcat, we may encounter a very slow startup situation and we will see information similar to the following in the startup log.
<DATE> org.apache.catalina.util.SessionIdGenerator createSecureRandomINFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [5172] millionseconds.
For this question, please refer to the official description at the end of the official article.
Question description:
Tomcat 7+ heavily relies on SecureRandom class to provide random values for its session ids and in other places. Depending on your JRE it can cause delays during startup if entropy source that is used to initialize SecureRandom is short of entropy
Tomcat7+ relies heavily on the random values provided by the SecureRandom class for session ids and elsewhere, which can cause delays in startup.
Solution:
There is a way to configure JRE to use a non-blocking entropy source by setting the following system property: -Djava.security.egd=file:/dev/./urandom
Translation: Add jvm parameter - Djava.security.egd=file:/dev/./urandom
[cjh@iZwz9catu2mrq92b07d1d0Z bin]$ pwd/home/cjh/apache-tomcat-7.0.82/bin//Add the parameter after the opening comment [cjh@iZwz9catu2mrq92b07d1d0Z bin]$ vi catalina.sh...JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom"...//View jvm running parameters, the parameter has been added [cjh@iZwz9catu2mrq92b07d1d0Z bin]$ jps -v...//Rerun tomcat to view the startup log, the startup time is normal...
3. Install the reverse proxy nginx
//Installing nginx[root@iZwz9catu2mrq92b07d1d0Z ~]# yum -y install nginx//After the installation is completed, check the configuration file path [root@iZwz9catu2mrq92b07d1d0Z ~]# whereis nginx//Check the configuration file content, you can find that the configuration file group contained in another path [root@iZwz9catu2mrq92b07d1d0Z ~]# cat /etc/nginx/nginx.conf...include /etc/nginx/conf.d/*.conf;...//Switch the path and check the file group [root@iZwz9catu2mrq92b07d1d0Z ~]# cd /etc/nginx/conf.d/[root@iZwz9catu2mrq92b07d1d0Z conf.d]# ls -l | grep .conf-rw-r--r-- 1 root root 408 Nov 22 17:59 default.conf-rw-r--- 1 root root 686 Oct 31 2016 ssl.conf-rw-r--- 1 root root 283 Oct 31 2016 virtual.conf//Modify default.conf[root@iZwz9catu2mrq92b07d1d0Z conf.d]# vi default.conf...listen port number;server_name Domain name/ip;...//Start nginx[root@iZwz9catu2mrq92b07d1d0Z conf.d]# chkconfig nginx on[root@iZwz9catu2mrq92b07d1d0Z conf.d]# service nginx start//Access the domain name or ip on the browser and display the nginx welcome page and then the configuration is successful
4. Install MySQL
Download the official yum library
https://dev.mysql.com/downloads/repo/yum/
Installation Instructions
https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
//Download MySQL Yum library [root@iZwz9catu2mrq92b07d1d0Z ~]# wget https://repo.mysql.com//mysql57-community-release-el6-11.noarch.rpm//Installing the yum library [root@iZwz9catu2mrq92b07d1d0Z ~]# yum -y localinstall mysql57-community-release-el6-11.noarch.rpm//Check the library installation is successful, and the child library is enabled by default mysql57-community[root@iZwz9catu2mrq92b07d1d0Z ~]# yum -C repolist enabled//Installing MySQL5.7[root@iZwz9catu2mrq92b07d1d0Z ~]# yum -y install mysql-community-server//Start the service[root@iZwz9catu2mrq92b07d1d0Z yum.repos.d]# chkconfig mysqld on[root@iZwz9catu2mrq92b07d1d0Z ~]# service mysqld startInitializing MySQL database: [ OK ]Starting mysqld: [ OK ]
Note: The service will be initialized at the initial startup (5.7 only), the superuser will be created, and its password has been set and stored in /var/log/mysqld.log, not empty
A superuser account 'root'@'localhost' is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:
//The x value is the password of the database user root [root@iZwz9catu2mrq92b07d1d0Z ~]# cat /var/log/mysqld.log | grep password2017-11-22T14:27:56.638229Z 1 [Note] A temporary password is generated for root@localhost: x//Enter successful [root@iZwz9catu2mrq92b07d1d0Z ~]# mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or /g....
The above is the detailed content and steps on building a Java Web server compiled by the editor this time. I hope the content we have sorted out will be helpful to everyone. Thank you for your support for Wulin.com.