Apache 的 httpd.conf 配置文件

http.conf 是 Apache 的配置文件,Apache 的常见配置主要是通过修该文件实现的,修改之后需要

重启 Apache 服务生效。

Httpd.conf

#Apache 安装目录

ServerRoot “/usr/local/apache2”

#Apache 监听端口

Listen 80

<ifMoudle !mpm_netware_moudle>

<ifMoudel !mpm_winnt_moudle>

#Apache 进程执行者

User daemon

#Apache 进程执行者所属的用户组

Group daemon

</ifMoudle>

</ifMoudle>

#网站管理员邮箱

ServerAdmin you@example.com

DoucmentRoot “/usr/local/apache2/htdocs”

#设置根目录访问权限

<Directory />

Options FollowSymLinks AllowOverride None Order deny,allow

Deny from all

</Directory>

Options:配置在特定目录使用哪些特性,常用的值有:

ExecCGI:在该目录下执行 CGI 脚本

FollowSymLinks:在该目录下允许文件系统使用符号连接

Indexes: 当用户访问该目录时,如果用户找不到 DirectoryIndex 指定的主页文件(例如 index.html),

则返回该目录下的文件列表给用户。

SymLinksIfOwnerMatch: 当使用符号连接时,只有当符号连接的文件拥有者与实际文件的拥有者

相同时才可以访问。

#设置/usr/local/apache2/htdocs 目录权限

<Directory “/usr/local/apache2/htdocs”>

Options Indexes FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

#AllowOverride:允许存在.htaccess 文件中的指令类型

#None:当 AllowOverride 设置 None 时,不搜索该目录下的.htaccess

#All:在.htaccess 文件中使用所有指令

#Allow:允许访问的主机列表(可用域名或子网,例如:Allow from 192.168.0.0/16)。

#Deny:拒绝访问的主机列表。

#DirectoryIndex index.html index.htm index.php #主页文件的设置(本例将主页文件设置为:

index.html,index.htm 和 index.php)

#设置首页为 index.html

<ifMoudle dir_module>

DirectoryIndex index.html

</ifMoudle>

ErrorLog 参数:用于指定记录,Apache 运行过程中所产生的错误信息和日志文件的位置

LogLevel 参数:用于指定文件中记录错误信息的级别,设置不同级别

原文地址:https://www.cnblogs.com/fanweisheng/p/11327804.html