Getting Started with Apache server under linux ---- httpd.conf

If you install apache centos, the system itself has installed the apache, the httpd service is the name for the corresponding

 

service httpd start 
service httpd stop
service httpd restart


Here are some of several important apache configuration files

 

1 httpd.conf

The file / etc / httpd / conf directory, the file is roughly divided into three parts:

Master section

This part is to use some of the parameters defined in the server and much more.

 

### Section 1: Global Environment

ServerTokens OS
...
ServerRoot "/etc/httpd" ---------定义与服务器所在的目录,这个目录在安装时由-prefix=ServerRoot 来选定
...
PidFile run/httpd.pid
...
Timeout 60
...
KeepAlive Off
...
MaxKeepAliveRequests 100
...
KeepAliveTimeout 15
...
ServerAdmin root@localhost-----------定义当服务器出现错误后提示给客户端的管理员邮件地址
#ServerName www.example.com:80----------定义apache默认的主机名字,但默认备注释掉
DocumentRoot "/var/www/html"----------指令用于指定apache所提供页面服务的根目录
Alias /error/ "/var/www/error/"-----------实现映射目录功能,映射为一个普通目录
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"----------实现映射,与Alias不同的是它将映射的目录识别为CGI脚本目录并将此目录中的所有文件都作为CGI脚本来对待
User apache
Group apache--------定义运行apache服务器的账号和工作组,用来定义用户请求时所创建的子进程的账号与工作组
#Listen 12.34.56.78:80--------定义监听端口号,默认是80
Listen 80
# Example:---------------------------------------------------用于加载模块的目标文件
# LoadModule foo_module modules/mod_foo.so
#
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_alias_module modules/mod_authn_alias.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule ldap_module modules/mod_ldap.so
# Some examples:---------------------------当错误时,apache定义一个http相应代码,并根据相应代码显示相应网页
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
    <Directory "/var/www/error">
        AllowOverride None
        Options IncludesNoExec----------------决定在那些目录中使用那些服务器的特性
        AddOutputFilter Includes html
        AddHandler type-map var
        Order allow,deny
        Allow from all
        LanguagePriority en es de fr
        ForceLanguagePriority Prefer Fallback
    </Directory>

 


Container environment section

<IfModule> acts on the module, it first determines whether loading, and then decide whether to process.

 

<IfModule mod_dav_fs.c>
    # Location of the WebDAV lock database.
    DAVLockDB /var/lib/dav/lockdb
</IfModule>

 

<IfDefine> and above <IfModule> Similarly, only when the corresponding conditions are met, it will be performed.

<Directory> module effect it is encapsulated in an instruction to play a role in a subdirectory in the specified directory, the directory must be a complete path.

 

<Directory "/var/www/error">
        AllowOverride None
        Options IncludesNoExec
        AddOutputFilter Includes html
        AddHandler type-map var
        Order allow,deny
        Allow from all
        LanguagePriority en es de fr
        ForceLanguagePriority Prefer Fallback
    </Directory>

<Files> The container <Directory> container acting on the corresponding directory, <Files> container to act only on file

 

 

<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>

<Location> to match the incoming URL

 

 

#<Location /server-status>
#    SetHandler server-status
#    Order deny,allow
#    Deny from all
#    Allow from .example.com
#</Location>

 

 

Server extension

This section is mainly used Inlcude to load configuration file

 

Include conf.d/*.conf

In /etc/httpd/conf.d directory:

 

 

[root@localhost httpd]# cd conf.d/
[root@localhost conf.d]# ls
mod_dnssd.conf  README  welcome.conf
[root@localhost conf.d]#



 

 

Reproduced in: https: //my.oschina.net/u/204616/blog/545133

Guess you like

Origin blog.csdn.net/weixin_34292959/article/details/91989987