安装apache2
1 . 优化连接数。进入apache安装目录,编辑/server/mpm/worker/worker.c文件,修改参数为#define DEFAULT_SERVER_LIMIT 2560和# define DEFAULT_THREAD_LIMIT 500
2. 编译
./configure --prefix=/home/apache2 --enable-mods-shared='all cache mem-cache disk-cache file-cache' --enable-deflate --enable-rewrite --enable-headers --enable-expires --enable-modules="most" --enable-suexec --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr --enable-rewrite --with-mpm=worker --with-perl --enable-maintainer-mode --enable-so --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-proxy-ajp --enable-proxy-balancer --with-z=/usr/lib
make
make install
3. apache http.conf 加入
<IfModule mpm_worker_module>
ServerLimit 50
ThreadLimit 100
StartServers 3
MaxClients 5000
MinSpareThreads 75
MaxSpareThreads 250
ThreadsPerChild 100
MaxRequestsPerChild 80000
</IfModule>
启动apache测试。
编译resin3.1.5
./configure -with-apxs=/home/apache2/bin/apxs
make
make install
部署工程。
例子:xx工程 /home/user/workspace/xxeSystem
xxSystem子目录:xxProject(存放代码)、 bin(存放resin启动和关闭代码)、 conf(resin.conf)、 log
静态代码 for apache(html、js、css、image);放到: /home/www/xxProject(工程名)
chown -R daemon:daemon xxProjectt/ (修改权限,apache能访问)
bin的启动代码 start.sh
#!/bin/sh
WORK_PATH=/home/user/workspace/xxSystem
#resin安装目录
RESIN_HOME=/home/user/software/resin-3.1.5
#jdk目录
JAVA_HOME=/home/user/software/jdk1.6.0_03
#如果resin需要工程下的jar包;下面的注释去掉
#CLASSPATH=.;
#libpath=$WORK_PATH/webapp/WEB-INF/lib/
#FILES=`ls $libpath`
#for txt in $FILES;
#do
# CLASSPATH=$CLASSPATH:$libpath$txt
#done
#echo $CLASSPATH
export RESIN_HOME CLASSPATH JAVA_HOME
$RESIN_HOME/bin/httpd.sh -server xx -conf $WORK_PATH/conf/resin.conf start
#-server search -Xms256m -Xmx512m
stop.sh
#!/bin/sh
WORK_PATH=/home/user/workspace/xxSystem
RESIN_HOME=/home/user/software/resin-3.1.5
JAVA_HOME=/home/user/software/jdk1.6.0_03
export RESIN_HOME JAVA_HOME
$RESIN_HOME/bin/httpd.sh -server xx -conf $WORK_PATH/conf/resin.conf stop
配置apache
vi conf/http.conf
hosts Include conf/extra/httpd-vhosts.conf (注释去掉)
去掉deny from all
添加mod_expires可以减少10%左右的重复请求
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 days"
ExpiresByType text/html "access plus 1 days"
ExpiresByType text/css "access plus 1 days"
ExpiresByType image/gif "access plus 1 days"
ExpiresByType image/jpeg "access plus 1 days"
ExpiresByType image/jpg "access plus 1 days"
ExpiresByType image/png "access plus 1 days"
EXpiresByType application/x-shockwave-flash "access plus 1 days"
EXpiresByType application/x-javascript "access plus 1 days"
ExpiresByType video/x-flv "access plus 1 days"
</IfModule
vi conf/extra/httpd-vhosts.conf
Listen 1111
NameVirtualHost *:1111
<VirtualHost *:1111>
ServerAdmin [email protected]
DocumentRoot "/home/www/xxProject/webapp"
ServerName url
ResinConfigServer localhost 6803
</VirtualHost>
备注:6803为resin server端口 <server id="xx" address="127.0.0.1" port="6803"/>