apache的配置文件在哪 (apache bench)

Apache 配置

1、*载下**apache

2、 ./configure \

--prefix=/usr/local/apache2.2.32 \

--enable-deflate \

--enable-headers \

--enable-expires \

--enable-modules=most \

--enable-so \

--with-mpm=worker \

--enable-rewrite

3、 make

4、make install

配置文件

一、/usr/local/apache/conf/httpd.conf 内容解析

Server root 服务的根目录

Listen 80 监听的端口

Server admin you@example.com管理员邮箱

Servername www.yeyiboy.com 网站名

Documentroot /usr/local/apache/htdocs 站点目录,需改成自己的站点目录

<Directory /> 表示根目录拒绝其他人访问

Options FollowSymLinks

AllowOverride None 禁止相关功能

Order deny,allow 不让任何人访问根目录

Deny from all 不让任何人访问根目录

</Directory>

新增加站点目录,必须增加下面六行,否则网站打不开

<Directory "/usr/local/apache2.2.32/htdocs"> 把站点目录/usr/local/apache2.2.32/htdocs改成自己的站点目录

Options Indexes FollowSymLinks 如去掉Indexes,站点目录如果没有首页也不会暴露站点目录。为了安全,通常配置会去掉。

AllowOverride None

Order allow,deny

Allow from all

</Directory>

<IfModule dir_module>

DirectoryIndex index.html 指定访问首页,如果有多个首页,都列出,空格隔开

</IfModule>

ErrorLog "logs/error_log" 错误日志

去掉include conf/extra/ httpd-mpm.conf和include conf/extra/ httpd-vhosts.conf 前面的#号

二、/usr/local/apache/conf/extra 扩展的配置文件

1、 httpd-mpm.conf

<IfModule mpm_prefork_module> 工作模式为prefork模式。默认为该模式。#Apache共两种模式,prefork和worker

StartServers 5

MinSpareServers 5

MaxSpareServers 10

MaxClients 150

MaxRequestsPerChild 0

</IfModule>

<IfModule mpm_worker_module> 工作模式为worker模式,编译时已指定为worker模式。

StartServers 2

MaxClients 150

MinSpareThreads 25

MaxSpareThreads 75

ThreadsPerChild 25

MaxRequestsPerChild 0

</IfModule>

2、 httpd-vhosts.conf 配置网站大部分在这里配置

NameVirtualHost *:80 基于域名的服务,一个主机想跑多个网站在这里配置

3、httpd-default.conf 了解

Timeout 300 超时

KeepAlive On 连接保持

MaxKeepAliveRequests 100 最大接受多少个连接

KeepAliveTimeout 5 等待下一个连接时间

AccessFileName .htaccess 设置伪静态

ServerTokens Full 隐藏apache版本

ServerSignature On 隐藏apache版本

FQDN 完整的域名解析

错误报告:httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Syntax OK

解决办法: vim /usr/local/apache/conf/httpd.conf

把 servername www.example.com:80 增加成servername 127.0.0.1:80