我们公司是好多tomcat服务器都是用的https。 当然https有其优点(不罗嗦了!),https使用443端口
1:安装jdk,
[root@localhost ~]# ls jdk-1_5_0_19-linux-i586.bin
jdk-1_5_0_19-linux-i586.bin
[root@localhost ~]# pwd
/root
[root@localhost ~]# chmod a+x jdk-1_5_0_19-linux-i586.bin
[root@localhost ~]# ./jdk-1_5_0_19-linux-i586.bin
在当前目录下生成jdk1.5.0_19目录。
我把它移到/usr/local目录下。
[root@localhost ~]# mv jdk1.5.0_19 /usr/local/
[root@localhost local]# ln -s jdk1.5.0_19 jdk
下面是配置路径:
[root@localhost local]# vi /etc/profile
在文件的最后加入:
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
然后运行如下命令使得不重启机器就生效:
[root@localhost local]# source /etc/profile
2:安装tomcat, 其实上面配置路径就是为了tomcat能正常启动, 因为tomcat启动时需要用到到jdk,
[root@localhost local]# tar zxvf apache-tomcat-5.5.26.tar.gz
[root@localhost local]# ln -s apache-tomcat-5.5.26 tomcat5.5
3:生成证书:
[root@localhost ~]# keytool -genkey -alias .keystore -keyalg RSA
Enter keystore password: hellohello
What is your first and last name?
[Unknown]: liu #
这项要和你linux server的机器名一样,这样有好处!查linux server的机器名,可以用hostname命令
What is the name of your organizational unit?
[Unknown]: bea
What is the name of your organization?
[Unknown]: bea
What is the name of your City or Locality?
[Unknown]: suzhou
What is the name of your State or Province?
[Unknown]: suzhou
What is the two-letter country code for this unit?
[Unknown]: cn
Is CN=liu, OU=bea, O=bea, L=suzhou, ST=suzhou, C=cn correct?
[no]: yes
Enter key password for <.keystore>
(RETURN if same as keystore password): hellohello
尤其注意:两次输入的密码一定要一样!而且生成的.keystore的位置在~下(我用的是root,故在/root下)
[root@localhost ~]# find / -name .keystore
/root/.keystore
然后复制该文件到/usr/local/tomcat5.5下(我tomcat安装在/usr/local目录下!)
查看该文件的时候用ls -a
4:对server.xml做配置,
[root@localhost ~]# cd /usr/local/tomcat5.5/
[root@localhost tomcat5.5]# ls
bin common conf LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt server shared temp webapps work
[root@localhost tomcat5.5]# pwd
/usr/local/tomcat5.5
[root@localhost tomcat5.5]# ls -a
. .. bin common conf .keystore LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt server shared temp webapps work
[root@localhost tomcat5.5]# cd conf/
[root@localhost conf]# ls
Catalina catalina.policy catalina.properties context.xml logging.properties server-minimal.xml server.xml tomcat-users.xml web.xml
[root@localhost conf]# pwd
/usr/local/tomcat5.5/conf
[root@localhost conf]# vi server.xml
修改部分如下:
先把关于下面的注视去掉:
443" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
keystoreFile="/usr/local/tomcat/.keystore"
keystorePass="hellohello"
clientAuth="false" sslProtocol="TLS" />
粗体是我修改的部分
4: 启动tomcat
[root@localhost conf]# cd /usr/local/tomcat5.5/
[root@localhost tomcat5.5]# ls
bin common conf LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt server shared temp webapps work
[root@localhost tomcat5.5]# cd bin/
[root@localhost bin]# ls
bootstrap.jar commons-logging-api-1.1.1.jar jmxaccessor-tasks.xml shutdown.bat tomcat5w.exe version.bat
catalina.bat cpappend.bat jsvc.tar.gz shutdown.sh tomcat-juli.jar version.sh
catalina.sh digest.bat service.bat startup.bat tomcat-native.tar.gz
catalina-tasks.xml digest.sh setclasspath.bat startup.sh tool-wrapper.bat
commons-daemon.jar jkstatus-tasks.xml setclasspath.sh tomcat5.exe tool-wrapper.sh
[root@localhost bin]# pwd
/usr/local/tomcat5.5/bin
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat5.5
Using CATALINA_HOME: /usr/local/tomcat5.5
Using CATALINA_TMPDIR: /usr/local/tomcat5.5/temp
Using JRE_HOME: /usr/local/jdk
[root@localhost bin]# netstat -antl | grep 443
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN
[root@localhost bin]#
这里tomcat已经启动了。
5:测试:启动浏览器,
阅读(2111) | 评论(0) | 转发(0) |