An explanation of Apache's main directory and configuration file

Source: Internet
Author: User
Tags sendfile fully qualified domain name

One, Apache main configuration file Comment
Apache master configuration file:/etc/httpd/conf/httpd.conf
Default site home directory:/var/www/html/
Apache server configuration information is stored in the main configuration file/etc/httpd/conf/httpd.conf, the content of this file is very large, with the WC command to count a total of 1009 lines, most of which is the # beginning of the comment line.

Servertokens OS
Whether the name of the server operating system is displayed when the error page appears, Servertokens prod is not displayed

ServerRoot "/ETC/HTTPD"
Used to specify the run directory of Apache, after the service starts, it automatically changes the directory to the current directory, and all the relative paths used later are intended for this directory

User Daemon # Apache, default to Daemon
Group Daemon # Apache user, default is daemon

Pidfile Run/httpd.pid
The PID number of the httpd daemon is recorded, this is the method that the system recognizes a process, the system httpd process can have multiple, but this PID corresponding process is other parent process

Timeout 60
Time the server and client were disconnected

KeepAlive OFF
Whether to continue the connection (because each connection will have three handshake, if it is not a small amount of traffic, it is recommended to open this item, if the site traffic is relatively large close this item is better), modified to: KeepAlive on means to allow the procedural online

Maxkeepaliverequests 100
Represents the maximum number of requests for a connection

KeepAliveTimeout 15
The time before the connection is disconnected

<ifmodule prefork.c>
Startservers 8
Minspareservers 5
Maxspareservers 20
Serverlimit 256
MaxClients 256
Maxrequestsperchild 4000
</IfModule>
The system default module, which indicates that a process is started for each access (that is, when there are multiple connections to a common process, only one is available at the same time).
StartServer starts the service with 8 processes, with a minimum of 5 processes and up to 20 processes free.
Maxclient limit the maximum number of connection requests for clients at the same time to enter the waiting queue.
Maxrequestsperchild the maximum number of requests allowed for a service per process lifetime, 0 means never ending

<ifmodule worker.c>
Startservers 4
MaxClients 300
Minsparethreads 25
Maxsparethreads 75
Threadsperchild 25
Maxrequestsperchild 0
</IfModule>
Configure thread access for Apache, which is to start a thread for each access to the Web service, which is a smaller memory footprint.
The Serverlimit server allows you to configure the maximum number of processes.
Threadlimit the maximum thread that can be configured per child process
Startservers starts two httpd processes,
MaxClients can initiate up to 250 accesses at the same time, exceeding the product size of the Serverlimit and threadsperchild to enter the queue waiting.
Threadsperchild the number of resident execution threads per child process lifetime, and no longer increases after the child thread is established
Maxrequestsperchild the maximum number of threads to start per process, such as when a limit is reached, the process ends, such as 0, the child thread never ends

Listen 80
Listen on the port, if there are multiple network cards, the default listener all network cards

LoadModule Auth_basic_module modules/mod_auth_basic.so
......
LoadModule Version_module modules/mod_version.so
Modules loaded at startup

Include conf.d/*.conf
The loaded configuration file

The identity that is converted after the service is started, usually as root when the service is started, then the identity is converted, which increases system security

ServerAdmin [email protected] #管理员的邮箱, if there is a problem, will be displayed on the first page

#ServerName www.example.com:80
The default is no need to specify, the server through the name resolution process to obtain its own name, but if the resolution is a problem (such as reverse parsing is incorrect), or there is no DNS name, you can also specify the IP address here, when this is incorrect when the server does not start normally. Before starting Apache when prompted is starting Httpd:httpd:apr_sockaddr_info_get () failed Forjustin httpd:could not reliably determine the server ' s fully qualified domain name, using 127.0.0.1forServerName, the solution is to start the item to change the WWW.EXAMPLE.COM:80 to its own domain name or directly to localhost

Usecanonicalname OFF
If the client provides a host name and port, Apache will use this information provided by the client to build the self-referencing URL. These values are the same as the values used to implement the domain-based virtual host and are available to the same client. CGI variables server_name and server_port are also built by the values provided by the client.

DocumentRoot "/var/www/html" # Apache's default Web site directory path, do not add a slash at the end

<directory/> #行为对根目录的限制
Options FollowSymLinks # followsymlinks means that symbolic links are allowed, which is disabled by default
AllowOverride None # Indicates that the user is prevented from overloading the directory configuration file (. htaccess), and the normal site is not recommended to open
</Directory>

<directory "/var/www/html" >
Options Indexes FollowSymLinks
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
A permission setting for the/var/www/html directory, the options indexes means that the index is allowed to display files in the directory when the page does not exist, followsymlinks whether to allow access to the symbolic link file. There are options for whether the execcgi table uses CGI, such as options includes execcgi followsymlinks, which allows the server to execute CGI and SSI, prohibiting listing of directories. Symlinksownermatch means that access is allowed when the file and destination files for the symbolic link are owned by the same user. Allowoverridenone indicates that access control files in this directory are not allowed to change the configuration, which means that you do not have to look at the access control files under this directory and modify them to: allowoverride all means allow. htaccess. The order's access control sequence for a page is the default option, such as Allow,deny, which defaults to Deny,allowfromall, which allows all users to control access to the Web site by combining the previous

<ifmodule mod_userdir.c>
Userdir disabled
</IfModule>
Whether to allow users to access their home directory, the default is not to allow

#<directory/home/*/public_html>
# allowoverride FileInfo authconfig Limit
# Options MultiViews Indexes symlinksifownermatch includesnoexec
# <limit GET POST options>
# Order Allow,deny
# Allow from all
# </Limit>
# <limitexcept GET POST options>
# Order Deny,allow
# Deny from all
# </LimitExcept>
#</directory>
If you allow access to a Web page file in the user's home directory, the above comment is canceled and modified

DirectoryIndex index.html Index.html.var #指定所要访问的主页的默认主页名字, default home file name is index.html

Accessfilename. htaccess #定义每个目录下的访问控制文件名, the default is. htaccess

<files ~ "^\.ht" >
Order Allow,deny
Deny from all
Satisfy All
</Files>
Control does not allow users on the web to view. HTPASSWD and. htaccess Two files

Typesconfig/etc/mime.types #用于设置保存有不同MIME类型数据的文件名

DefaultType Text/plain #默认的网页的类型

<ifmodule mod_mime_magic.c>
# Mimemagicfile/usr/share/magic.mime
Mimemagicfile Conf/magic
</IfModule>
Specifies the module that determines the true MIME type of the file

Hostnamelookups Off #当打开此项功能时, while logging the log at the same time the host name, which requires the server to reverse the resolution of the domain name, increase the load on the server, usually not recommended to open

#EnableMMAP off
Whether to allow memory mapping: If httpd needs to read the contents of a file during delivery, it can use memory mapping. If on indicates that a memory map will be used if the operating system supports it. On some multi-core processors, this may degrade performance if this feature is turned on on DocumentRoot that Mount NFS, which can cause httpd crashes due to fragmentation

#EnableSendfile off
This command controls whether httpd can use the Sendfile support of the operating system kernel to send files to the client. By default, when processing a request does not require access to the data inside the file (such as sending a static file content), if the operating system supports it, Apache will use Sendfile to send the file content directly to the client without reading the file

Errorlog Logs/error_log #错误日志存放的位置
LogLevel warn #Apache日志的级别

Logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" combined
Logformat "%h%l%u%t \"%r\ "%>s%b" common
Logformat "%{referer}i,%u" Referer
Logformat "%{user-agent}i" Agent
The format of the log is defined and represented by a different code name

#CustomLog Logs/access_log Common
Customlog Logs/access_log combined
Describes the location of the log record, which uses a relative path, so serverroot need to point out that the log location is stored in the/etc/httpd/logs

Serversignature on #定义当客户请求的网页不存在, or if the error prompts you for some information about the Apache version

alias/icons/"/var/www/icons/" #定义一些不在DocumentRoot下的文件, and it can be mapped to the root of the Web page, which is also a way to access other directories, but in the declaration of the time remember to add "/" after the directory

<directory "/var/www/icons" >
Options Indexes multiviews FollowSymLinks
AllowOverride None
Order Allow,deny
Allow from all
</Directory>
Define permissions on/var/www/icons/, modify to Options multiviews followsymlinks to show no tree structure on browser

<ifmodule mod_dav_fs.c>
# Location of the WebDAV lock database.
Davlockdb/var/lib/dav/lockdb
</IfModule>
Management of the MOD_DAV_FS.C module

scriptalias/cgi-bin/"/var/www/cgi-bin/" #对CGI模块儿的的别名, similar to Alias

<directory "/var/www/cgi-bin" >
AllowOverride None
Options None
Order Allow,deny
Allow from all
</Directory>
Management of/var/www/cgi-bin folder, same method as above

# Redirect Old-uri New-url
The redirect parameter is used to rewrite the URL, and when the browser accesses a resource that does not already exist on the server, the server returns a new URL to the browser, telling the browser to get the resource from the URL. This is primarily used when the document that originally existed on the server changes location, but also need to be able to use the old URL to access the original page

Indexoptions fancyindexing versionsort namewidth=* HTMLTable charset=utf-8
Addiconbyencoding (cmp,/icons/compressed.gif) x-compress X-gzip
...
Indexignore.?? * *~ *# header* readme* RCS CVS *,v *,t
When the URL of an HTTP request is a directory, the server returns the index file in this directory, if the index file does not exist in the directory, and the server has a license to display the list of directory files, the list of files in this directory will be displayed, in order to make this list of files understandable, Rather than just a simple list, these parameters need to be the first. If you use the indexoptionsfancyindexing option, you can have the server refer to different icons for different files. If not, use DefaultIcon to define the default icon. Similarly, using adddescription can involve a description of different types of documents

AddLanguage ca. ca
......
AddLanguage ZH-TW. zh-tw
Add language

Languagepriority en CA cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-br Ru SV ZH-CN ZH-TW
Languages supported by Apache

Adddefaultcharset UTF-8 #默认支持的语言

#AddType Application/x-tar. tgz #支持的应用如果想支持对php的解析添加这样一行

#AddEncoding x-compress. Z
#AddEncoding x-gzip. gz. tgz
Support to the. Files ending in Z and. gz.tgz

AddType application/x-compress. Z
AddType application/x-gzip. gz. tgz
Add an application to both of these files

#AddHandler cgi-script. CGI #修改为: AddHandler cgi-script. cgi. PL to allow CGI scripts that have the. pl extension to run
AddType text/html. shtml
Addoutputfilter includes. shtml
Add a dynamic processing type of server-parsed the tags in the Web page are pre-parsed by the server, changing the tag to the correct HTML identity

#ErrorDocument 404/missing.html #当服务器出现404错误的时候, return to missing.html page
alias/error/"/var/www/error/" #赋值别名

<ifmodule mod_negotiation.c>
<ifmodule mod_include.c>
<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>
Permissions and actions on the/var/www/error Web page

Browsermatch "MOZILLA/2" nokeepalive
Browsermatch "MSIE 4\.0b2;" Nokeepalive downgrade-1.0 force-response-1.0
Browsermatch "RealPlayer 4\.0" force-response-1.0
Browsermatch "java/1\.0" force-response-1.0
Browsermatch "jdk/1\.0" force-response-1.0
.....
Set special parameters to ensure compatibility with older browsers and support the features of new browsers

#NameVirtualHost *:80 #如果启用虚拟主机的话, the preceding comments must be removed, and the contents of the second section can appear in each virtual host section.
# VirtualHost Example:
#<virtualhost *:80>
# ServerAdmin [email protected]
# documentroot/www/docs/www.linuxidc.com
# ServerName Www.linuxidc.com
# errorlog Logs/www.linuxidc.com-error_log
# Customlog Logs/www.linuxidc.com-access_log Common
#</virtualhost>
www.linuxidc.com Replace with your URL

Second, Apache extended configuration file
$APACHE _home/conf/extra # APACHE Extended configuration file
[Email protected]]# ll
Total 56
-rw-r--r--1 root root 2859 Jan 01:49 httpd-autoindex.conf
-rw-r--r--1 root root 1753 Jan 01:49 httpd-dav.conf
-rw-r--r--1 root root 2344 Jan 01:49 httpd-default.conf
-rw-r--r--1 root root 1103 Jan 01:49 httpd-info.conf
-rw-r--r--1 root root 5078 Jan 01:49 httpd-languages.conf
-rw-r--r--1 root root 932 Jan 01:49 httpd-manual.conf
-rw-r--r--1 root root 3789 Jan 01:49 httpd-mpm.conf
-rw-r--r--1 root root 2207 Jan 01:49 httpd-multilang-errordoc.conf
-rw-r--r--1 root root 11185 Jan 01:49 httpd-ssl.conf
-rw-r--r--1 root root 817 Jan 01:49 httpd-userdir.conf
-rw-r--r--1 root root 1507 Jan 01:49 httpd-vhosts.conf # Virtual Host configuration file


Iii. httpd-vhosts.conf Virtual Host profile comments
[Email protected]]# egrep-v "^.*#|^$" httpd-vhosts.conf |nl
1 namevirtualhost *:80 # NAME-based virtual host configuration (*:80 indicates all IP listening on this machine)
2 <virtualhost *:80> # define a virtual host
3 ServerAdmin [email protected] # Configure admin mailbox
4 DocumentRoot "/application/apache2.2.22/docs/dummy-host.example.com" # program's Site Directory
5 ServerName dummy-host.example.com # Domain Name service, requires Apache Mode_alias module support
6 Serveralias www.dummy-host.example.com # Virtual Host Alias
7 Errorlog "Logs/dummy-host.example.com-error_log" # error log path
8 Customlog "Logs/dummy-host.example.com-access_log" common #访问日志配置 (production environment we use combined format instead of common format)
9 </VirtualHost>
Ten <virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "/application/apache2.2.22/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
Errorlog "Logs/dummy-host2.example.com-error_log"
Customlog "Logs/dummy-host2.example.com-access_log" common
</VirtualHost>


Iv. Directory of Apache service storage sites
$APACHE _home/apache/htdocs # Default to the path of the Web page, enter the IP to this directory to see it ' s wroks! This is the directory
[Email protected]]# less index.html




V. Apache Service Directory Structure description
[Email protected]]# ls. /
Bin build Cgi-bin conf error htdocs icons include lib logs man manual modules
Bin Startup file Directory description
|--Bin # Apache Service Command Directory
| |--AB # HTTP service performance test tool
| |--apachectl # Apache boot command
| |--Apr-1-config
| |--Apu-1-config
| |--APXS # HTTP service compiles and installs extension modules using the tool, which is used when the DSO mode module is compiled
| |--Checkgid
| |--Dbmmanage
| |--Envvars
| |--ENVVARS-STD
| |--Htcacheclean # Control command to clean up disk buffers
| |--htdbm
| |--Htdigest
| |--htpasswd # Create and update basic certification files
| |--httpd # httpd for Apache Control command Program
| |--httxt2dbm
| |--Logresolve
| --Rotatelogs # Apache comes with a Day poll command (Cronolog production environment uses more).


Conf configuration file Directory
[Email protected]]# ls. /conf/
Extra httpd.conf Magic Mime.types Original
/application/apache/conf/# Apache Configure all profile directories
|--Extra # Additional Apache configuration file directory such as: httpd-vhost.conf
| |--httpd-autoindex.conf
| |--httpd-dav.conf
| |--httpd-default.conf
| |--httpd-info.conf
| |--httpd-languages.conf
| |--httpd-manual.conf
| |--httpd-mpm.conf
| |--httpd-multilang-errordoc.conf
| |--httpd-ssl.conf
| |--httpd-userdir.conf
| |--httpd-vhosts.conf
|--httpd.conf # Apache master config file
|--Magic
|--Mime.types
|--Original
| |--Extra
|   | |--httpd-autoindex.conf
|   | |--httpd-dav.conf # DAV support configuration
|   | |--httpd-default.conf # This file is configured with Apache related service parameters: Timeout time, keep link
|   | |--httpd-info.conf
|   | |--httpd-languages.conf # language Support
|   | |--httpd-manual.conf
|   | |--httpd-mpm.conf # Server pool management, is also a configuration file to optimize Apache (Apache mode and configure the number of links, common mode for worker mode and profork mode, default porfork)
|   | |--httpd-multilang-errordoc.conf
|   | |--httpd-ssl.conf # provides Apache SSL support configuration file
|   | |--httpd-userdir.conf
|   | |--httpd-vhosts.conf # Configuration file for virtual machines
| |--httpd.conf


Site Storage Directory
[Email protected]]# ls-l htdocs/# The default home file is placed in this directory.
Total 4
-rw-r--r--1 root root (2004 index.html


Log storage Directory
[Email protected] apache]# tree logs
Logs # Apache service default log path, including error log and access log
|--Access_log # Apache service Access Log tail-f command to view information on Web page user access
|--cgisock.16406
|--error_log # Apache Service error log. Example: Apache service startup failure
|--httpd.pid # httpd pid file, when the HTTP process starts, it writes the ID number of all processes to this file


Module Catalog
[[Email protected]]# ls-l manual/# Apache's module directory such as PHP Mencache
Total 2984
-rw-r--r--1 root root 543 May 6 bind.html
-rw-r--r--1 root root 11422 Jan 3 bind.html.de


An explanation of Apache's main directory and configuration file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.