在配置Tomcat之前, 我们要先对Tomcat相关目录给予权限:
lib目录: army@linux03:/usr/share/tomcat7$ sudo chown -R army:army lib
tomcat7目录:army@linux03:/etc/tomcat7$ sudo chown -R army *
tomcat7权限:army@linux04:/etc$ sudo chmod 777 -R tomcat7
/var/tomcat目录: 用于存放部署的项目.
如果var下没有tomcat目录:army@linux03:/var$ sudo mkdir tomcat
army@linux03:/var/tomcat$ sudo mkdir blog
army@linux03:/var/tomcat$ cd blog/
army@linux03:/var/tomcat/blog$ sudo mkdir app
army@linux03:/var/tomcat/blog$ sudo mkdir logs
army@linux03:/var/tomcat/blog$ sudo mkdir bak
修改/var/tomcat目录下权限:
army@linux03:/var$ sudo chown -R army:army tomcat
army@linux03:/var$ sudo chmod 777 -R tomcat
Tomcat启动: army@linux04:/$ sudo service tomcat7 start
Tomcat停止: army@linux04:/$ sudo service tomcat7 stop
Tomcat重启: army@linux04:/$ sudo service tomcat7 restart
查看Tomcat详细Log:
army@linux04:/var/log/tomcat7$ more catalina.2015-12-21.log
army@linux04:/var/log/tomcat7$ cat catalina.2015-12-21.log
army@linux04:/var/log/tomcat7$ tail -n 50 catalina.2015-12-21.log
修改Hosts文件:
army@linux03:/etc$ sudo vim hosts
修改Tomcat内存分配, 和端口号设置:
army@linux04:/etc/default$ sudo vim tomcat7
JAVA_OPTS="-Djava.awt.headless=true -Xms1024M -Xmx2048M -XX:MaxPermSize=384M -XX:+UseConcMarkSweepGC" AUTHBIND=yes
打开443端口号:
sudo apt-get install authbind sudo touch /etc/authbind/byport/443 sudo chmod 500 /etc/authbind/byport/443 sudo chown tomcat7 /etc/authbind/byport/443
修改server.xml文件:
<Connector executor="tomcatThreadPool" port="8620" protocol="HTTP/1.1" connectionTimeout="120000" redirectPort="443" acceptCount="600" maxThreads="500" compression="on" useSendfile="false" compressionMinSize="2048" noCompressionUserAgents="gozilla,traviata" compressableMimeType="text/html,text/xml,text/css,text/plain,application/json,application/javascript,text/javascript" /> <Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" connectionTimeout="120000" acceptCount="600" maxThreads="500" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="/etc/tomcat7/self_signed_cert_20150922.keystore" keystorePass="china8620" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata" ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA" compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/vnd.ms-excel,application/pdf,application/json"/> <Connector port="8009" protocol="AJP/1.3" redirectPort="443" />
<Host name="blog.army16.com" unpackwars="true" autoDeploy="true" xmlvalidation="false" xmlNamespaceAware="false"> </Host>