httpd.conf配置文件:
ServerTokens Prod
ServerSignature Off
Timeout 180
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
StartServers 2
ServerLimit 30
MaxClients 3000
MinSpareThreads 75
MaxSpareThreads 600
ThreadsPerChild 100
MaxRequestsPerChild 10000
UseCanonicalName Off
HostnameLookups Off
AddDefaultCharset GB2312
AddType application/x-tar .tgz
AddType application/x-httpd-php .php
DocumentRoot "/home/admin/cai/htdocs"
ServerRoot "/home/admin/cai"
ServerAdmin
[email protected]
ServerName taobao.com
PidFile /home/admin/cai/logs/httpd.pid
Listen 80
User admin
Group admin
LoadModule authz_host_module /opt/taobao/install/httpd/modules/mod_authz_host.so
#LoadModule include_module /opt/taobao/install/httpd/modules/mod_include.so
LoadModule deflate_module /opt/taobao/install/httpd/modules/mod_deflate.so
LoadModule log_config_module /opt/taobao/install/httpd/modules/mod_log_config.so
#LoadModule env_module /opt/taobao/install/httpd/modules/mod_env.so
LoadModule mime_magic_module /opt/taobao/install/httpd/modules/mod_mime_magic.so
#LoadModule expires_module /opt/taobao/install/httpd/modules/mod_expires.so
#LoadModule headers_module /opt/taobao/install/httpd/modules/mod_headers.so
LoadModule setenvif_module /opt/taobao/install/httpd/modules/mod_setenvif.so
LoadModule mime_module /opt/taobao/install/httpd/modules/mod_mime.so
LoadModule dir_module /opt/taobao/install/httpd/modules/mod_dir.so
LoadModule alias_module /opt/taobao/install/httpd/modules/mod_alias.so
LoadModule rewrite_module /opt/taobao/install/httpd/modules/mod_rewrite.so
#LoadModule php4_module /opt/taobao/install/httpd/modules/libphp4.so
LoadModule php5_module /opt/taobao/install/httpd/modules/libphp5.so
#LoadModule cgid_module /opt/taobao/install/httpd/modules/mod_cgid.so
LoadModule fcgid_module /opt/taobao/install/httpd/modules/mod_fcgid.so
#LoadModule fastcgi_module /opt/taobao/install/httpd/modules/mod_fastcgi.so
LoadModule evasive20_module /opt/taobao/install/httpd/modules/mod_evasive20.so
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
BrowserMatch "^gnome-vfs" redirect-carefully
ErrorDocument 400 /home/error.html
ErrorDocument 403 /home/error.html
ErrorDocument 404 /home/error.html
ErrorDocument 405 /home/error.html
ErrorDocument 408 /home/error.html
ErrorDocument 410 /home/error.html
ErrorDocument 411 /home/error.html
ErrorDocument 412 /home/error.html
ErrorDocument 413 /home/error.html
ErrorDocument 414 /home/error.html
ErrorDocument 415 /home/error.html
ErrorDocument 500 /toolarge.html
ErrorDocument 501 /toolarge.html
ErrorDocument 502 /toolarge.html
ErrorDocument 503 /toolarge.html
ErrorDocument 506 /toolarge.html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
DirectoryIndex index.php
TypesConfig /etc/mime.types
DefaultType text/plain
<IfModule mod_mime_magic.c>
MIMEMagicFile /opt/taobao/install/httpd/conf/magic
</IfModule>
<Location />
SetOutputFilter DEFLATE
# SetEnvIfNoCase Request_URI ^/auction/checkcode$ no-gzip
</Location>
##========================================================================================
#DDOS路脌脫霉脛拢驴茅脡猫脰脙
##===========================
<IfModule mod_evasive20.c>
DOSHashTableSize 4000
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
</IfModule>
##===========================
##===========================
ErrorLog "|/opt/taobao/install/cronolog/sbin/cronolog /home/admin/cai/logs/cronolog/%Y/%m/%Y-%m-%d-error_log"
LogLevel warn
LogFormat "%h %l %u %t \"%m
http://%V%U%q\"%>s%b\"% {Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog
SetEnvIf Remote_Addr "192\.168\." dontlog
SetEnvIf Remote_Addr "10\.0\." dontlog
SetEnvIf Remote_Addr "60\.191\.55\.49" dontlog
SetEnvIf Request_URI "^/robots\.txt$" dontlog
SetEnvIf Request_URI "\.swf$" dontlog
SetEnvIf Request_URI "\.gif$" dontlog
SetEnvIf Request_URI "\.jpg$" dontlog
SetEnvIf Request_URI "\.ico$" dontlog
SetEnvIf Request_URI "\.jpeg$" dontlog
SetEnvIf Request_URI "\.bmp$" dontlog
SetEnvIf Request_URI "\.png$" dontlog
SetEnvIf Request_URI "\.js$" dontlog
SetEnvIf Request_URI "\.css$" dontlog
SetEnvIf Request_URI "\.wav$" dontlog
SetEnvIf Request_URI "\.swf$" dontlog
SetEnvIf Request_URI "home/css" dontlog
CustomLog "|/opt/taobao/install/cronolog/sbin/cronolog /home/admin/cai/logs/cronolog/%Y/%m/%Y-%m-%d-taobao-access_log" combined env=
!dontlog
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
IPCCommTimeout 40
IPCConnectTimeout 10
DefaultInitEnv RAILS_ENV production
SocketPath /tmp/fcgidsock
</IfModule>
#AddHandler fastcgi-script .fcgi
NameVirtualHost *
<VirtualHost *>
ServerName rails.taobao.com
DocumentRoot /home/admin/rails/rails.taobao.com/public
ErrorLog /home/admin/rails/logs/rails_taobao_com.log
<Directory "/home/admin/rails/">
Options Indexes ExecCGI FollowSymLinks
AllowOverride all
Allow from all
Order allow,deny
</Directory>
RewriteEngine on
</VirtualHost>
另外public下的.htaccess和dispatch.fcgi稍做改动,我的如下:
.htaccess:
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
dispatch.fcgi:
#!/usr/local/bin/ruby
require File.dirname(__FILE__) + "/../config/environment"
require 'fcgi_handler'
RailsFCGIHandler.process!