标签:
Apache的基本配置
1.监听套接字[ip : port]
2.实现持久连接(keep alive)
3.MPM模块
命令行中执行
core.c : 核心模块
prefork.c : prefrok模块
http_core.c: http核心模块
mod_so.c : 支持动态DSO机制模块注:
httpd –l :显示支持的非DSO模块
httpd -m:显示已装载的DSO模块
prefork模型的参数
<IfModule prefork.c>
StartServers 8 在启动httpd的默认启动的子进程数
MinSpareServers 5 httpd主进程维持最少空闲子进程数
MaxSpareServers 20 httpd主机厂维持的最大空闲子进程数
ServerLimit 256 同一(并发)时间允许的最大活动进程数
MaxClients 256 并发请求的最大值
MaxRequestsPerChild 4000 在每个子进程的生命周期内所能够接收的请求数
</IfModule>
worker模型的参数
<IfModule worker.c>
StartServers 4 在启动httpd的时候,所启动的子进程数
MaxClients 300 能接收的最大并发请求数
MinSpareThreads 25 每个子进程所维护最小线程数
MaxSpareThreads 75 每个子进程所维护最大线程数
ThreadsPerChild 25 每个子进程所能产生的线程数
MaxRequestsPerChild 100 每个线程在生命周期内所能够处理的请求数量,0表示不做限制
</IfModule>
4.DSO动态装载模块
方式:LoadModule ModuleName /path/to/Module(是相对路径,相对ServerRoot)
例子:装载PHP模块
LoadModule php5_module /etc/httpd/modules/php5_module.so(在配置文件修改/etc/httpd/conf/httpd.conf)
5.网站根目录
DocumentRoot /path/to/somewhere
默认位置:/var/www/html
注:如果修改网站根目录,必须保证Apache对此目录有读权限
6.网页访问属性
设置用户访问指定目录中的文件的时候的属性
<Directory "/path/to/somewhere">
Option 访问控制类选项
AllowOverride 设置apache的配置文件是否可以被另个覆盖
Order
allow
</Directory>常用AllowOverride:none不允许,all允许,authconfig表示使用基于用户的方式来做认证
7.默认文档
DirectoryIndex
8.用户目录
让每个用户可以在自己家目录下创建个人网站
<IfModule mod_userdir.c>
UserDir disabled 禁止个人用户创建自己的站点
#UserDir public_html 指定目录名
</IfModule>
9.日志功能
日志存放位置:/var/log/httpd
定义访问日志
CustomLog "/path/to/logFile" FormatName
logFormat FormatString FormatName
%h: 记录客户端地址
%l:远程登录名,通常 -
%u:用身份认证的时候显示用户名,-
%t:收到客户端请求的时间
%r:请求报文的起始行
%(user-agent)
%(refer)例子:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
10.路径别名
Alias /alias/ /path/to/somewhere
11.设置默认字符集
AddDefaultChareset
12.CGI脚本别名
CGI:Common Gateway Interface
CGI:执行脚本,将执行脚本结果返回给用户
脚本程序:
遵循cgi
Content-Type:text/html
脚本具有执行权限(SUID,SGID)
将脚本保存在特定目录中
mod_alias
mod_cgi
定义脚本别名
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
Author:潇湘雨错
标签:
原文地址:http://www.cnblogs.com/xiaoxiangyucuo/p/5690056.html