天天看點

Apache伺服器配置與使用工作筆記

uname -m -oecho "/usr/local/apache/lib" >> /etc/ld.so.confhwclock -w #将時間寫入BIOSconfig.layout./configure --enable-layout=xxx.layoutapachectl -k startstatusproc httpdinetd#apachectlgracefulgraceful-stopconfigteststatusfullstatus#一個配置檔案中啟動多個apacheListen 443

DocumentRoot "xx"httpd -D SSL###################################httpd參數-f xx.conf-e warn-E xx.error-v-V  version -t  test config##################監控APACHE子產品mod_statusSetHandler server-status

Order deny,allow

Deny from all

Allow from 192.168.1.2ExtendedStatus On###############################http://ip/server-status?autohttpd -M  #what modules have been loaded#############安裝mod_log_access子產品wget http://www.gjvc.com/software/Apache/modules/mod_log_access-1.03.tar.gztar zxf mod_log_access-1.03.tar.gzcd mod_log_access-1.03#mod MakefileAPACHE_PREFIX=/usr/local/apacheAPACHE_VERSION=2.2.21make && make install#####################################config add moduleLoadModule env_module libexec/mod_env.soClearModuleListAddModule mod_env.so#########################yum -y install mod_perlorwget http://perl.apache.org/dist/mod_perl-2.0-current.tar.gztar zxvf mod_perl-2.0-current.tar.gz && cd mod_perl-2.0.5perl Makefile.PL MP_APXS=/usr/local/apache/bin/apxsmake && make installhttpd -M | grep perl#########加速perl腳本Alias /perl/ /usr/local/apache/cgi-bin/SetHandler perl-script

PerlResponseHandler ModPerl::Registry

PerlOptions +ParseHeaders

Options +ExecCGI

Order allow,deny

Allow from all########################dirctoryfileslocationDirectoryIndexInclude conf/extra/httpd-autoindex.confwebmin gui config toolredhat-config-httpd  gui config toolservernameserveraliasdocumentrootifconfig eth0:0 122.222.222.222 netmask xxx upAddHandler cgi-script .cgi .pl###添加自己的CGI腳本處理程式AddHandler myfiletype .xyAction myfiletype /cgi-bin/program.cgiorSetHandler xx

Action xx /xx.cgi virtual ############################script GET /xx.cgiOptions +ExecCGIssipermanent  temp  seeother  gonerewriteengine onRewriteRule pattern substitution flagsRewriteCondpt:繼續處理F:403  G:410  L:該URL不再被重寫  NC:忽略大小寫  P:交給代理處理RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteLogLevel 0  #禁止重寫日志RewriteEngine OnRewriteRule ^/$ /FAQ/ [R]CheckSpelling on  無視URL[R,L]#proxyOrder Deny,Allow

Allow from www.xxx.comAllowCONNECT NoProxyProxyBlockProxyDomainProxyPass xx !ProxyPass /  http://www.xx.comProxyPassReverse  URL不會被重寫CacheDefaultExpire  10    secondCacheDisable  /bin    不緩存CacheEnable mem/fd/disk /bin 用記憶體 檔案 硬碟記憶體緩存子產品LoadModule cache_module modules/mod_cache.soLoadModule mem_cache_module modules/mod_mem_cache.soCacheEnable mem /src/ww/

MCacheMaxObjectCount 100

MCacheMaxObjectSize 1

MCacheMaxStreamingBuffer 65535

MCacheMinObjectSize

MCacheRemovalAlgorithm GDSF

MCacheSize 10240LoadModule cache_module modules/mod_cache.soLoadModule disk_cache_module modules/mod_disk_cache.soCacheRoot /var

CacheEnable disk /

CacheDirLevels 5

CacheDirLength 3mod_file_cache  //無法緩存CGICacheFile /src/index.htmlnmapfile /src/index.html圖檔和動态内容一般轉發到其他伺服器Proxypass /img http://img.jonsk.comProxypassreverss /img http://img.jonsk.com#禁止代理伺服器轉發電子郵件Rewriteengine on

Rewriterule "^proxy:[a-z]*://[^/]*:25(/|$)" "-" [F,NC,L]Proxyblock ww.xx.com#mod_dbd連結DB需要安裝apr-utils24小時進行分割CustomLog "|/usr/local/apache/bin/rotatelogs log/access_log 86400" commonCustomLog "|/usr/bin/rotatelogs log/access_log_%Y%m%d 86400 480" combinedErrorLog syslog:local7webalizerawstats#不記錄日志SetEnvIfNoCase Referer "xxx"  no_img=1CustomLog logs/access_log combined env=!no_img${Referer}i        引用頁面ab -n 1000 -c 10 http://www.baidu.comRequire valid-usermod_security 安全檢查nikto 對網站進行檢查chkrootkit 系統漏洞檢查HostnameLookups off  DNS負載均衡htpasswd -c .htpasswd jonskhtpasswd -D .htpasswd jonshtpasswd .htpasswd jonskAuthType Basic AuthName "Rest Files"AuthUserFile /xxx/apasswdorder deny,allowAllow from all--enable-ssl