日期:2014-05-16 浏览次数:21166 次
Apache 常用配置与说明? http://javadoc.org.cn/home.php?mod=space&uid=2&do=blog&id=20?
适应于个人相整点事情,小公司主机资源不是很富余,投资约1W含一年托管费,练手者就可以不看了,没什么必要,浪费时间,基本按这些说明下来搞定。
安装apache,svn,tomcat等参与我的其它相关播客 <Directory "/var/soft/sites/wikso/ROOT/WEB-INF"> Order allow,deny </Directory> #禁止访问 /var/soft/sites/wikso/ROOT/WEB-INF目录 ServerSignature Off ServerTokens Prod #关闭apache响应版本等特征信息 LoadModule authz_host_module modules/mod_authz_host.so LoadModule dav_module modules/mod_dav.so LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so LoadModule authz_owner_module modules/mod_authz_owner.so LoadModule authn_file_module modules/mod_authn_file.so LoadModule auth_basic_module modules/mod_auth_basic.so LoadModule authz_user_module modules/mod_authz_user.so LoadModule jk_module modules/mod_jk.so #加载 svn tomcat连接模块 JkWorkersFile "/var/soft/bin/apache/conf/workers.properties" JkLogFile "/var/soft/bin/apache/logs/mod_jk.log" JkLogLevel emerg JkShmFile /var/soft/bin/apache/logs/mod_jk.shm #Tomcat 连接模块配置信息,日志等 LoadModule setenvif_module modules/mod_setenvif.so LoadModule log_config_module modules/mod_log_config.so SetEnvIf Request_URI /a/* aimages SetEnvIf Request_URI "\.jpg$" aimages SetEnvIf Request_URI "\.png$" aimages SetEnvIf Request_URI "\.gif$" aimages SetEnvIf Request_URI /dwr/* aimages LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined #CustomLog "|/usr/local/sbin/cronolog /var/soft/bin/apache/logs/access_log.%Y%m%d" combined env=!aimages #设置日志记录条件 AddType application/x-httpd-php .php .phtml AddType applicatoin/x-httpd-php-source .phps #加载PHP模板 LoadModule rewrite_module modules/mod_rewrite.so #加载重定向模板,设置防盗链 NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin web@javadoc.org.cn DocumentRoot /var/soft/sites/javadoc/ ServerName www.javadoc.org.cn ServerAlias javadoc.org.cn RewriteEngine on RewriteCond %{HTTP_HOST} !^javadoc.org.cn [NC] RewriteRule ^(.*)$ http://javadoc.org.cn$1 [R] ErrorLog "logs/javadoc-error_log" LogFormat "%h %{Host}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedhost CustomLog "|/usr/local/sbin/cronolog /var/soft/bin/apache/logs/javadoc/access_log.%Y%m%d" combinedhost env=!aimages </VirtualHost> #防盗链只要设在第一个VirtualHost 就可以,其它的会以主机名对应,第一个会对应所以的IP,当其它的主机没有匹配上时 #按天记录日志 <VirtualHost *:80> ServerName svn.javadoc.org.cn <Location /> DAV svn SVNParentPath /var/soft/sites/svn/ AuthType Basic AuthName "Subversion repository" AuthUserFile /var/soft/bin/apache/bin/userfile AuthzSVNAccessFile /var/soft/bin/apache/conf/authz Require valid-user </Location> </VirtualHost> #SVN设置 <VirtualHost *:80> DocumentRoot /var/soft/sites/wikso/ROOT/ ServerName www.wikso.com ServerAlias wikso.com *.wikso.com JkUnMount /a/* worker1 JkMount /* worker1 ErrorLog "logs/wikso-error_log" CustomLog "|/usr/local/sbin/cronolog /var/soft/bin/apache/logs/wikso/access_log.%Y%m%d" combined env=!aimages </VirtualHost> #tomcat整合+日志 其它部分部分 LogFormat %{Host}i 指出请求的主机名,可记录盗链的主机域名 CustomLog cronolog 实现按天存 workers.properties文件内容 workers.tomcat_home=/var/soft/tomcat6 workers.java_home=/usr/java/jdk1.6.0_20 worker.list=worker1 worker.worker1.port=8009 worker.worker1.host=localhost worker.worker1.type=ajp13 worker.worker1.connection_pool_timeout=600 worker.worker1.socket_keepalive=1 worker.worker1.lbfactor=1