TongWeb的安装
本帖最后由 lqph3387 于 2011-1-6 08:41 编辑一,安装TongWeb5.0应用程序
TongWeb5.0需要在操作系统hosts文件中定义本机IP地址,并以本机的IP优先。如下所示:
192.168.12.1 localhost
127.0.0.1 localhost
[tongweb@app9 ~]$useradd tongweb && su - tongweb
[tongweb@app9 ~]$sh Install_TW5.0.0.0_Linux.bin -i console
在Linux平台上安装TongWeb5.0,出现如下信息:
Preparing to install...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...
Launching installer...
Preparing CONSOLE Mode Installation...
===================================================================TongWeb5.0 (created with InstallAnywhere)
-------------------------------------------------------------------------------
===================================================================License Agreement
-----------------
Installation and Use of TongWeb5.0 Requires Acceptance of the Following License
Agreement:
End user license agreement for Tongtech co., LTD software
The End user license agreement will be accompanied with the products and
related documents of Tongtech co., LTD. Please read it carefully. You will
be asked to accept this license and continue the installation. If you do
not accept this license, you should refuse it and quit the installation.
Grant of license:
Tongtech co., LTD grants you the license to use the software program, but you
must make such assurance as following to our company: Do not
use¡¢copy¡¢modify¡¢rent or convey this system besides the terms listed in this
license and the formal contact signed with Tongtech co., LTD.
You guarantee:
1. Using this software only on a single computer;
2. For the purpose of backup or archival management for the use on one
computer, making copy of this system by machine-reading format.
You guarantee not:
1. Transfer license of this system again.
2. Getting source codes of this system by altering, modifying, translating,
reversing, anti-editing, anti-compiling or any other methods.
PRESS <ENTER> TO CONTINUE:
2. 出现如上信息后,按回车键继续安装。
3. Copy or transfer this software in whole or in part.
When you transfer this software in part or in whole to any third part, your
right to use the software shall terminate immediately and without notice.
The copyright and ownership of this software:
The copyright of this software is owned by Tongtech co., LTD. The structures,
tissues and codes are the most valuable commercial secrets of Tongtech co.,
LTD. This software and documents are protected by national copyright laws and
international treaty provisions. You are not allowed to delete the copyright
notice from this software. You must agree to prohibit any kind of illegal copy
of this software and documents.
Limited warranty:
In the largest permitting area of the law, In no situation shall Tongtech
co., LTD be liable for any special, unexpected, direct or indirect damages
(including, without limitation, damages for loss of business profits, business
interruption, loss of business information, or any other pecuniary loss)
arising out of the use of or inability to use this product and the providing or
inability to provide supporting services, even if Tongtech co., LTD has been
advised of the possibility of such damages.
PRESS <ENTER> TO CONTINUE:
3. 出现如上信息后,按回车键继续安装。
Termination:
Tongtech co., LTD may terminate the license at any time if you violate any
term or condition of the license. When the license is terminated, you must
destroy all copies of the software and all of its documents immediately, or
return them to Tongtech co., LTD.
Law:
"Intelligent Property Protection Regulation", "Copyright Law", "Exclusive Law"
Now, you must have already carefully read and understand this license, and
agreed to obey all the terms and conditions strictly.
DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N): y
4. 出现如上信息后,请选择是否接受许可条款,若接受请输入y。
===============================================================================
Choose Install Folder
---------------------
Where would you like to install?
Default Install Folder: /home/tongweb/TongWeb5.0
ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT
: /usr/local/TongWeb5.0
5. 出现如上信息后,请输入安装路径,若同意使用给出的默认安装路径,请按回车键继续安装。
===================================================================
Pre-Installation Summary
------------------------
Please Review the Following Before Continuing:
Product Name:
TongWeb5.0
Install Folder:
/usr/local/TongWeb5.0
Link Folder:
/usr/local/TongWeb5.0
Disk Space Information (for Installation Target):
Required: 139,934,247 bytes
Available: 40,788,152,320 bytes
PRESS <ENTER> TO CONTINUE:
6. 出现如上信息后,请确认预安装信息是否正确,若正确请按回车键继续安装。
===============================================================================
Installing...
-------------
[==================|==================|==================|==================]
[------------------|------------------|------------------|------------------]
===============================================================================
Installation Complete
---------------------
Congratulations. TongWeb5.0 has been successfully installed to:
/usr/local/TongWeb5.0
PRESS <ENTER> TO EXIT THE INSTALLER:
7. 出现如上信息后,表示成功安装产品,按回车键结束安装。
二,安装License
在TongWeb5.0产品光盘中提供有license文件。TongWeb5.0 license文件目前包含如下控制:
1. 版本
2. 有效期
安装方法:将TongWeb5.0产品光盘中的license.dat文件复制到安装完成的TongWeb5.0根目录下。
三,启动TongWeb服务器
TongWeb5.0安装成功后,使用TongWeb5.0_HOME/bin目录下的startserver.sh启动TongWeb5.0应用服务器
[tongweb@app9 ~]$sh /usr/local/TongWeb5.0/bin/startserver.sh &
四,登陆控制台测试
http://IP:9060/twns/ 默认用户名和密码均为twns
五,加入开机自动启动
[tongweb@app9 ~]$echo '/bin/su -c "/usr/local/TongWeb5.0/bin/startserver.sh &" tongweb' >> /etc/rc.local
Apache 结合php
Apache主配置文件为:/usr/local/apache2/conf/httpd.conf# vim /usr/local/apache2/conf/httpd.conf
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加
AddType application/x-httpd-php .php
找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
将该行改为
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
找到:
#Include conf/extra/httpd-mpm.conf
#Include conf/extra/httpd-info.conf
#Include conf/extra/httpd-vhosts.conf
#Include conf/extra/httpd-default.conf
去掉前面的“#”号,取消注释。
jdk1.6的安装
一,在sun的官方(https://cds.sun.com/is-bin/INTER ... R@CDS-CDS_Developer) 下载jdk-6u15-linux-i586.bin,上传至/usr/local/src目录[root@host1 ~]# cd /usr/local/src
[root@host1 src]# chmod a+x jdk-6u15-linux-i586.bin
[root@host1 src]# sh jdk-6u15-linux-i586.bin
此时会出现JDK 安装授权协议。可以一路按Enter浏览,当出现Do you agree to the above license terms? [yes or no] 的字样。输入yes即可
[root@host1 src]# mv jdk1.6.0_15 /opt
二,设置环境变量
[root@host1 src]#vim /etc/profile
在末尾输入以下内容
#set java environment
JAVA_HOME=/opt/jdk1.6.0_15/
JAVA_BIN=/opt/jdk1.6.0_15/bin
JRE_HOME=/opt/jdk1.6.0_15/jre
PATH=$PATH:/opt/jdk1.6.0_15/bin:/opt/jdk1.6.0_15/jre/bin
CLASSPATH=/opt/jdk1.6.0_15/jre/lib:/opt/jdk1.6.0_15/lib:/opt/jdk1.6.0_15/jre/lib/charsets.jar
export JAVA_HOME JAVA_BIN JRE_HOME PATH CLASSPATH
执行命令source /etc/profile,使配置立即生效
[root@host1 src]#source /etc/profile
三,测试
[root@host1 src]# java -version
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) Server VM (build 14.1-b02, mixed mode)
出现以上信息则表示安装成功
Apache防盗链设置
说明:本文来自网络位置一般情况下在 /usr/local/apache/conf/httpd.conf
或者apache 2.2 的 /usr/local/apache2/conf/extra/httpd-vhost.conf
添加
SetEnvIfNoCase Referer "^http://www.ccvita.com" local_ref=1
SetEnvIfNoCase Referer "^http://ccvita.com" local_ref=1
<filesmatch "\.(txt|doc|mp3|zip|rar|jpg|gif)">
Order Allow,Deny
Allow from env=local_ref
</filesmatch>
还一种写法,是用正则的,这种写法在各个版本的apache比较通用。
写法是
SetEnvIfNoCase Referer "^<strong>http://.*\.yourdomin\.com</strong>" local_ref=1
SetEnvIfNoCase Referer "<strong>.*\.yourdomin\.com</strong>" local_ref=1
<filesmatch "\.(txt|doc|mp3|zip|rar|jpg|gif)">
Order Allow,Deny
Allow from env=local_ref
</filesmatch>
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/qianling3439/archive/2009/02/05/3864248.aspx
tomcat的安装
本帖最后由 lqph3387 于 2011-1-5 10:10 编辑一,在tomcat的官方http://tomcat.apache.org/下载tomcat相应的版本,本文下载的版本是apache-tomcat-6.0.18.tar.gz,然后上传至/usr/local/src目录
[root@host1 ~]# cd /usr/local/src
[root@host1 src]# tar -zxvf apache-tomcat-6.0.18.tar.gz
[root@host1 src]#mv apache-tomcat-6.0.18 /usr/local/tomcat
二,修改tomcat启动脚本,并加入sysv服务
[root@host1 src]#cp –p /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat
[root@host1 src]#vim /etc/init.d/tomcat
在第二行加入以下内容
# chkconfig: 2345 63 37
# description: tomcat server init script
JAVA_HOME=/opt/jdk1.6.0_15/
CATALINA_HOME=/usr/local/tomcat
[root@host1 src]# chkconfig --add tomcat
[root@host1 src]#chkconfig tomcat on
三,加入内存控制的优化参数
[root@host1 src]#vim /etc/init.d/tomcat
搜索关键字$have_tty -eq 1,在if [ $have_tty -eq 1 ]; then行下增加:
JAVA_OPTS="-server -Xms800m -Xmx800m -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true "
四,启动并测试
[root@host1 src]# service tomcat start
[root@host1 src]#ps aux|grep tomcat
通过浏览器访问http://ip:8080/出现tomcat的主页面就安装成功了
配置tomcat容器的access.log访问日志
本帖最后由 lqph3387 于 2010-12-14 15:03 编辑编译server.xml文件,在
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
下追加如下信息:
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access." suffix=".log" pattern="combined" resolveHosts="false"/>
容器比较 tomcat jboss resion weblogic websphere
1. Tomcat是Apache鼎力支持的Java Web应用服务器,由于它优秀的稳定性以及丰富的文档资料,广泛的使用人群,从而在开源领域受到最广泛的青睐。­2. Jboss作为Java EE应用服务器,它不但是Servlet容器,而且是EJB容器,从而受到企业级开发人员的欢迎,从而弥补了Tomcat只是一个Servlet容器的缺憾。­
3. Resin也仅仅是一个Servlet容器,然而由于它优秀的运行速度,使得它在轻量级Java Web领域备受喜爱,特别是在互联网Web服务领域,众多知名公司都采用其作为他们的Java Web应用服务器,譬如163、ku6等。­商用应用服务器里主要有:Weblogic、Websphere,其中Weblogic我也使用过很长一段时间,当时也只用其当Servlet容器,然而就在同等条件下,在性能及易用性等方面,要比Tomcat优秀很多。
配置tomcat启动时的优化参数
本帖最后由 lqph3387 于 2010-12-14 14:23 编辑编译tomcat安装目录下的bin/catalina.sh文件,增加一句:JAVA_OPTS="-server -Xms800m -Xmx800m -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true "
具体做法,打开catalina.sh,搜索关键字$have_tty -eq 1,在if [ $have_tty -eq 1 ]; then行下增加:
JAVA_OPTS="-server -Xms800m -Xmx800m -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true "
修改后如下:
if [ $have_tty -eq 1 ]; then
JAVA_OPTS="-server -Xms800m -Xmx800m -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true "
echo "Using CATALINA_BASE: $CATALINA_BASE"
echo "Using CATALINA_HOME: $CATALINA_HOME"
echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
if [ "$1" = "debug" ] ; then
echo "Using JAVA_HOME: $JAVA_HOME"
else
echo "Using JRE_HOME: $JRE_HOME"
fi
echo "Using CLASSPATH: $CLASSPATH"
fi
apache 虚拟主机配置文档
E.配置Apache虚拟主机配置文件为:/usr/local/apache2/conf/extra/httpd-vhosts.conf
将配置文件中下面一段修改为如下:
<VirtualHost *:80>
# ServerAdmin [email protected]
DocumentRoot "/www/wwwroot/supesite"
ServerName www.www.com.cn
ErrorLog "|/usr/local/cronolog/sbin/cronolog /www/logs/error.log-%Y%m%d"
CustomLog "|/usr/local/cronolog/sbin/cronolog /www/logs/access.log-%Y%m%d" combined
</VirtualHost>
<VirtualHost *:80>
# ServerAdmin [email protected]
DocumentRoot "/www/wwwroot/ucenter"
ServerName uc.www.com.cn
ErrorLog "|/usr/local/cronolog/sbin/cronolog /www/logs/error.log-%Y%m%d"
CustomLog "|/usr/local/cronolog/sbin/cronolog /www/logs/access.log-%Y%m%d" combined
</VirtualHost>
<VirtualHost *:80>
# ServerAdmin [email protected]
DocumentRoot "/att/attachments"
ServerName att.www.com.cn
</VirtualHost>
说明:
ServerAdmin 参数后为管理员email
DocumentRoot 指的是论坛文件存放的目录
ServerName 是论坛的域名
ErrorLog 是论坛错误日志 通过管道使用cronolog工具将日志切割为每天一个文件
CustomLog 是论坛访问日志 通过管道使用cronolog工具将日志切割为每天一个文件
<IfModule mod_rewrite.c> 和</IfModule> 包含的字段是rewrite部分,实现URL静态化
配置tomcat的内置监控
本帖最后由 lqph3387 于 2010-12-14 14:42 编辑1,编译tomcat安装目录下的conf/tomcat-users.xml文件,在<tomcat-users>和</tomcat-users>之间注释或删除掉所有的默认账户和权限,新加一个权限如下:
<tomcat-users>
<role rolename="manager"/>
<user username="admin" password="adminws" roles="admin,manager"/>
</tomcat-users>
2,访问http://yourhost:port/manager/status 时给出admin的用户名与口令,就可以查看到应用服务器的相关性能指标数据
resin的安装
本帖最后由 lqph3387 于 2011-1-6 08:38 编辑在resin的官方http://www.caucho.com/下载resin相应的版本,本文下载的版本是resin-4.0.7.tar.gz ,然后上传至/usr/local/src目录
# tar -zxvf resin-4.0.7.tar.gz
# cd resin-4.0.7
# ./configure --prefix=/usr/local/www/resin --with-java-home=/usr/local/java
# make # make install
# groupadd resin
# useradd -g resin -s /sbin/nologin -M resin
# chown -R resin.resin /usr/local/www/resin
# vi /usr/local/www/resin/conf/resin.xml
修改如下两行内容:
<user-name>resin</user-name>
<group-name>resin</group-name>
/usr/local/www/resin/bin/resin.sh start
用http://hostip:8080即可访问到resin的默认页面
二、添加resin到系统服务
将make install生成的$RESIN_HOME/init.d/resin复制到/etc/init.d/resin
# cp init.d/resin /etc/init.d/resin
# chmod a+x /etc/init.d/resin
# vi /etc/init.d/resin添加如下两行
# chkconfig: 345 85 15
# description: Resin is a Java Web server.把type log_daemon_msg 1> /dev/null
修改为type echo 1> /dev/null
修改
case "$1" in
start)
....
stop)
.....
中的log_daemon_msg和log_end_msg为echo然后就可以用service resin start|stop来启动和停止resin了
三、resin管理员控制台
注:修改resin配置文件之前要先停止resin
使用http://hostip:8080 打开resin的默认页面
点击Administration is available here处的here
创建一个管理员
# cd /usr/local/www/resin/conf/
# service resin stop
# mv admin-users.xml.generated admin-users.xml
# service resin start然后就可以使用刚才创建的管理员登陆resin管理员控制台了
四、resin优化
1、优化JVM参数
修改resin.conf文件,在<server-default>节点下增加配置JVM参数的子节点<jvm-arg>。 -Xmx和-Xms的值需要根据服务器内存的大小调整,对于多数应用来说,-Xmx配置成1024M,完全能满足使用要求。通常将-Xms与-Xmx选项的值设置为相同,-Xmn的值为-Xmx的1/4。
<server-default>
<jvm-arg>-Xms1024m</jvm-arg>
<jvm-arg>-Xmx1024m</jvm-arg>
<jvm-arg>-Xmn256m</jvm-arg>
<jvm-arg>-XX:PermSize=128m</jvm-arg>
<jvm-arg>-XX:MaxPermSize=256m</jvm-arg>
<jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
</server-default>
2、调整图片Cache图片文件的时间
<web-app-default>
<cache-mapping url-pattern="*.gif" expires="6000s"/>
<cache-mapping url-pattern="*.jpg" expires="6000s"/>
<cache-mapping url-pattern="*.png" expires="6000s"/>
</web-app-default>
3、调整线程池的最大线程数
<server-default>
<thread-max>1024</thread-max>
</server-default>4、日志输出
如果不配置stdout-log,那么resin会把System.out输出的信息,自动输出到${resinHome}/log/jvm-default.log文件中,且这个文件不会按天存储,随着时间推移,这个文件会越来越大,最后影响系统效率。
<host>
<stdout-log path="${resinHome}/log/stdout.log" timestamp="[%Y-%m-%d %H:%M:%S.%s]" rollover-period="1D"/>
<stderr-log path="${resinHome}/log/stderr.log" timestamp="[%Y-%m-%d %H:%M:%S.%s]" rollover-period="1D"/>
</host>5、resin-server TIME_WAIT 过多的处理
thread-max指定了最大连接数,socket-timeout是socket超时时间
keepalive-max指定了长连接的数量,这是可以重复使用的连接,netstat -an时系统可以看到响应数量的ESTABLISHED状态
设定keepalive-max和把keepalive-timeout调小可以减少TIME_WAIT的数量。
在<server-default>节点下增加配置
<thread-max>10000</thread-max>
<socket-timeout>30s</socket-timeout>
<keepalive-max>512</keepalive-max>
<keepalive-timeout>60s</keepalive-timeout>6、调整检查程序更新时间间隔的配置
Resin 会在一个指定的周期内,检查一下web-app目录下的classes、jsp、jar以及配置文件是否更新,并且根据检查的情况,确定是否重新装载这些文件。对于生产系统来说,不会经常更新文件,时间间隔应该加长,提高系统的效率。文本框中配置的时间间隔为20分钟。
<dependency-check-interval>1200s</dependency-check-interval>
tomcat虚拟主机配置示范
本帖最后由 lqph3387 于 2010-12-14 15:08 编辑<Host name="www.cmdi.com" appBase="/data/www/wwwroot/www.cmdi.com"
unpackWARs="false" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="./" debug="0" reloadable="true" crossContext="true"/>
</Host>
以上的内容就是在linux系统中创建/data/www/wwwroot/www.cmdi.com文件夹作为www.cmdi.com这个域名的主目录,如果想配置这个域名的访问日志,如下:
<Host name="www.cmdi.com" appBase="/data/www/wwwroot/www.cmdi.com"
unpackWARs="false" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="./" debug="0" reloadable="true" crossContext="true"/>
<Logger className="org.apache.catalina.logger.FileLogger" directory="/data/www/logs" prefix="www_cmdi_com_access." suffix=".log" pattern="combined" timestamp="true"/>
</Host>



