centos中apache自用常用额外配置记录(xwamp)

xwamp套件中apache配置,记录下,以免忘记。

配置路径

${wwwroot_dir}/conf/httpd.conf

配置内容

<ifmodule mod_deflate.c>
  DeflateCompressionLevel 6
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  AddOutputFilter DEFLATE js css html htm
</ifmodule>

# 默认的运行模式
<IfModule mpm_prefork_module>
    StartServers             5
    MinSpareServers          5
    MaxSpareServers         10
    MaxRequestWorkers      250
    MaxConnectionsPerChild 10000
</IfModule>

# 运行模式 worker 更高的并发
<IfModule mpm_worker_module>
    StartServers             3
    MinSpareThreads         75
    MaxSpareThreads        250 
    ThreadsPerChild         25
    MaxRequestWorkers      400
    MaxConnectionsPerChild 10000
</IfModule>

# MaxMemFree 2MB
<IfModule !mpm_netware_module>
    MaxMemFree            2048
</IfModule>

Timeout 15
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5

TraceEnable off
HostnameLookups Off

<IfModule reqtimeout_module>
  RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500
</IfModule>

# 自定义日志格式
<IfModule log_config_module>
  LogFormat "%{%Y-%m-%d %H:%M:%S}t %h %>s %b "%r" "%{Referer}i" "%{User-Agent}i"" LogFormat_xwamp
</IfModule>

# 禁止某些请求头访问 比如:恶意蜘蛛
<Location />
  SetEnvIfNoCase User-Agent ".*(ZmEu|BLEXBot|MJ12bot|AhrefsBot|ChinasoSpider|DotBot|megaindex)" BADBOT
  Order allow,deny
  Allow from all
  deny from env=BADBOT
</Location>

# 不记录静态文件记录
<FilesMatch ".+.(ico|gif|jpg|swf|png|css|js)$">
  SetEnv STATICFILE 1
</FilesMatch>

<VirtualHost *:80>
  ServerAdmin admin@xwamp.com
  DocumentRoot "$wwwroot_dir/www"
  ServerName 127.0.0.1 
  ErrorLog $wwwroot_dir/logs/error.log
  CustomLog ${wwwroot_dir}/logs/access.log LogFormat_xwamp env=!STATICFILE
  php_admin_value open_basedir $wwwroot_dir/www:/tmp:/proc
<Directory "$wwwroot_dir/www">
  SetOutputFilter DEFLATE
  Options FollowSymLinks ExecCGI
  Require all granted
  AllowOverride All
  Order allow,deny
  Allow from all
  DirectoryIndex index.html index.php
</Directory>
<Location /server-status>
  SetHandler server-status
  Order Deny,Allow
  Deny from all
  Allow from 127.0.0.1
</Location>
</VirtualHost>

ProtocolsHonorOrder On
Protocols h2 http/1.1
PidFile /var/run/httpd.pid
ServerTokens ProductOnly
ServerSignature Off
Include ${wwwroot_dir}/conf/vhost-*.conf

结束。

原文地址:https://www.cnblogs.com/osfipin/p/7080703.html