a , installing the Java JDK Configuration environment variables
1, uninstall the original OpenJDK
yum-y Remove java-1.7.0-openjdk*
yum-y Remove Tzdata-java.noarch
2. Download the new JDK and unzip it
[email protected] java]# Curl-o http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u 79-linux-x64.tar.gz
[Email protected] java]# TAR-ZXVF jdk-7u79-linux-x64.tar.gz
There are a lot of ways to download the JDK, you can use the command or FTP in the local download after uploading to the CentOS up.
3. Configure Environment Variables
Vim/etc/profile through this directive into the Java configuration settings file, press I to enter the editing state, and then enter the following code at the end of the file. Java environment variable configuration complete
#set java environment
java_home=/usr/java/jdk1.7.0_79
Jre_home=/usr/java/jdk1.7.0_79/jre
Class_path=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/lib
Path= $PATH: $JAVA _home/bin: $JRE _home/bin
Export Java_home jre_home Class_path PATH
exit after completion [[email protected] java]# Source/etc/profile (Let the configuration you just modified take effect)
Then you can enter java-version and you can see the latest environment variables you've built.
two . Create an HTTPS access certificate and add the certificate to the Tomcat configuration
1. Create a certificate
First enter the following code into the bin directory of the Java_home:
cd/usr/java/jdk1.7.0_79/bin/
Keytool-genkey-alias tomcat-keyalg Rsa-keystore/usr/local/tomcat/tomcat.keystore-validi Ty 36500
Enter keystore Password: #此处需要输入大于6个字符的字符串
Re-enter new password:
What's your first and last name? # "What is your first and last name?" "This is required,
[Unknown]: haha
What is the name of your organizational unit? # What is the name of your organizational unit? "Can be filled as required or can not fill in the direct return, the experiment directly enter
[Unknown]:
What is the name of your organization? # "What is your organization name?" ", ibid. direct Carriage return
[Unknown]:
What's the name of your city or Locality? # "What is your city or region name?" , same as direct return
[Unknown]:
What's the name of your state or province? # "What is the name of your state or province?" ”
[Unknown]:
What's the Two-letter country code for this unit? # "What is the two-letter country code for this unit?" ”
[Unknown]:
Is cn=10.15.24.254, Ou=unknown, O=unknown, L=unknown, St=unknown, C=unknown correct? #系统询问 "right? , enter the letter "Y" with the keyboard if required, otherwise enter "n" to re-fill the information
[No]: Y
Enter Key Password for
(RETURN if same as KeyStore password): #输入的主密码, this is more important, it will be used in the Tomcat configuration file, the recommended input is consistent with the KeyStore password, setting other passwords can also
Re-enter new password:
2. Modify Tomcat's server.xml configuration file to support HTTPS
cd/tomcat/conf/
Vim Server.xml
Increase the node configuration of HTTPS, the following node in the Server.xml is present, but is commented out, you will uncomment, add two properties, one is the certificate path, one is the certificate password.
Third , firewall port configuration
vim/etc/sysconfig/iptables Enter port settings file Edit Status
It is important to note that there are no iptables files in the CentOS version, if you do not have to create a
Method of Creation: cd/etc/sysconfig/
Then execute: iptables-p OUTPUT ACCEPT service iptables save service iptables restart
Run after creation: vim/etc/sysconfig/iptables
The port for HTTP access settings in Tomcat is 8080, and I don't have this port set up, so HTTP access is obsolete. Only the default setting port for HTTPS in Https,tomcat is 8443
But HTTPS from the default port is 443 so as long as the 8443 in Tomcat is modified to 443 can be directly in front of the IP plus https://ip direct access.
Iv. The pits encountered in the construction
I use the CentOS server here is version 6.5, the system comes with OpenJDK 1.7.*, the first step to uninstall the system comes with the openjdk reason is because openjdk under the Toolkey generated certificate, is invalid certificate, cannot access HTTPS, you can use Curl-v HTTPS://IP after running, wait for an error number, and then open: http://www-archive.mozilla.org/projects/security/pki/nss/ref/ssl/ sslerr.html for comparison queries. Because this openjdk make me many times the environment, then suddenly thought may be this reason, online a check really someone said.
Yum Update NSS upgrade NSS, regardless of which version of CentOS you are in, you finally execute this code. Otherwise, you pass.
Curl Access IP will encounter NSS ERROR-59990
Build Tomcat HTTPS server under CentOS