Apache Master configuration file httpd.conf detailed

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

Http://www.linuxidc.com/Linux/2015-02/113921.htmApache's main 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.
[Email protected] ~]# wc-l/etc/httpd/conf/httpd.conf
1009/etc/httpd/conf/httpd.conf
[Email protected] ~]#

The configuration file consists of three parts:
[[email protected] ~]# grep ' \<section\> '/etc/httpd/conf/httpd.conf-n
33:### Section 1:global Environment
245:### Section 2: ' Main ' server configuration
973:### Section 3:virtual Hosts
[Email protected] ~]#

1) Global Environment---Global environment configuration, to determine the Apache server parameters
2) Main server configuration---The main service config, equivalent to the default Web site in Apache, if there is only one site in our server, then just configure it here.
3) Virtual hosts---Virtual hosts that cannot coexist with the main server master, and when the virtual host is enabled, main server cannot use the

--------------------------------------------------------------------------------
1) Global Environment

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


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


60 Timeout

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

102 <ifmodule Prefork.c>
103 Startservers 8
104 Minspareservers 5
Maxspareservers 20
106 Serverlimit 256
107 MaxClients 256
108 Maxrequestsperchild 4000
109 </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
118 <ifmodule Worker.c>
119 Startservers 4
300 maxclients
121 Minsparethreads 25
122 Maxsparethreads 75
123 Threadsperchild 25
124 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

136 Listen 80

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

123 LoadModule Auth_basic_module modules/mod_auth_basic.so
......
201 LoadModule Version_module Modules/mod_version.so

Modules loaded at startup

221 Include conf.d/*.conf

The loaded configuration file


242 User Apache
243 Group Apache

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

2) Main Server configuration


262 ServerAdmin [email protected]

Administrator's mailbox


276 #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. Front boot Apache when prompt 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


1 285 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.

292 DocumentRoot "/var/www/html"

directory where Web files are stored

302 <directory/>
303 Options FollowSymLinks
304 allowoverride None
305 </Directory>

Setting a permission on the root directory

317 <directory "/var/www/html" >
331 Options Indexes FollowSymLinks
338 allowoverride None
343 Order Allow,deny
344 Allow from all
346 </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>
366 userdir Disabled
375 </IfModule>

Whether to allow users to access their home directory, the default is not to allow

381 #<directory/home/*/public_html>
382 # allowoverride FileInfo authconfig Limit
383 # Options MultiViews Indexes symlinksifownermatch includesnoexec
384 # <limit GET POST options>
385 # Order Allow,deny
386 # allow from all
387 # </Limit>
388 # <limitexcept GET POST options>
389 # Order Deny,allow
390 # Deny from all
391 # </LimitExcept>
392 #</directory>

If you allow access to a Web page file in the user's home directory, the above comment is canceled and modified

402 DirectoryIndex index.html Index.html.var

Specifies the default home page name of the home page you want to access, and the default home file name is index.html

409 accessfilename. htaccess

Defines the access control file name under each directory, by default. htaccess

415 <files ~ "^\.ht" >
416 Order Allow,deny
417 Deny from all
418 Satisfy All
419 </Files>

Control does not allow users on the web to view. HTPASSWD and. htaccess Two files

425 Typesconfig/etc/mime.types

Used to set file names that hold data of different MIME types

436 DefaultType Text/plain

The type of the default Web page

443 <ifmodule mod_mime_magic.c>
444 # Mimemagicfile/usr/share/magic.mime
445 Mimemagicfile Conf/magic
446 </IfModule>

Specifies the module that determines the true MIME type of the file

456 hostnamelookups OFF

When this feature is turned on, the host name is recorded while logging, which requires the server to reverse resolve the domain name, increase the load on the server, usually does not recommend the opening

466 #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

475 #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

1 484 errorlog Logs/error_log

Where error logs are stored

491 LogLevel warn

Level of Apache logs

497 Logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" combined
498 Logformat "%h%l%u%t \"%r\ "%>s%b" common
499 Logformat "%{referer}i,%u" Referer
Logformat "%{user-agent}i" Agent

The format of the log is defined and represented by a different code name

513 #CustomLog Logs/access_log Common
526 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

536 Serversignature on

Defines some information about whether the page that the customer requested does not exist, or if the version of Apache is prompted for an error

551 alias/icons/"/var/www/icons/"

Define some files that are not under DocumentRoot, and you can map them to the root of the Web page, which is also a way to access other directories, but remember to add "/" to the directory after the declaration.

553 <directory "/var/www/icons" >
554 Options Indexes MultiViews followsymlinks
555 AllowOverride None
556 Order Allow,deny
557 Allow from all
558 </Directory>

Define permissions on/var/www/icons/, modify to Options multiviews followsymlinks to show no tree structure on browser

563 <ifmodule mod_dav_fs.c>
564 # Location of the WebDAV lock database.
565 DAVLOCKDB/VAR/LIB/DAV/LOCKDB
566 </IfModule>

Management of the MOD_DAV_FS.C module

576 scriptalias/cgi-bin/"/var/www/cgi-bin/"

Aliases for CGI modules are similar to alias.

582 <directory "/var/www/cgi-bin" >
583 allowoverride None
584 Options None
585 Order Allow,deny
586 Allow from all
587 </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

604 indexoptions fancyindexing versionsort namewidth=* HTMLTable charset=utf-8
611 Addiconbyencoding (cmp,/icons/compressed.gif) x-compress X-gzip
...
669 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

709 AddLanguage ca. ca
......
734 AddLanguage ZH-TW. zh-tw

Add language

743 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

759 Adddefaultcharset UTF-8

Supported languages by default

765 #AddType Application/x-tar. tgz

Supported applications if you want to support parsing of PHP add such a line

773 #AddEncoding x-compress. Z
774 #AddEncoding x-gzip. gz. tgz

Support to the. Files ending in Z and. gz.tgz

779 AddType application/x-compress. Z
780 AddType application/x-gzip. gz. tgz

Add an application to both of these files

796 #AddHandler Cgi-script. CGI

Modified to: AddHandler cgi-script. cgi. PL to allow CGI scripts that have the. pl extension to run

816 AddType text/html. shtml
817 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

833 #ErrorDocument 404/missing.html

Return to the Missing.html page when the server 404 error occurs

855 alias/error/"/var/www/error/"

Assignment aliases

857 <ifmodule mod_negotiation.c>
858 <ifmodule mod_include.c>
859 <directory "/var/www/error" >
860 allowoverride None
861 Options includesnoexec
862 Addoutputfilter includes HTML
863 AddHandler type-map var
864 Order Allow,deny
865 allow from all
866 languagepriority en es de fr
867 forcelanguagepriority Prefer Fallback
868 </Directory>

Permissions and actions on the/var/www/error Web page


895 Browsermatch "MOZILLA/2" nokeepalive
896 Browsermatch "MSIE 4\.0b2;" Nokeepalive downgrade-1.0 force-response-1.0
897 Browsermatch "RealPlayer 4\.0" force-response-1.0
898 Browsermatch "java/1\.0" force-response-1.0
899 Browsermatch "jdk/1\.0" force-response-1.0
.....

Set special parameters to ensure compatibility with older browsers and support the features of new browsers
3) Virtual Hosts

990 #NameVirtualHost *:80

If you enable a virtual host, you must remove the previous comment, and the contents of the second section can appear in each virtual host section.
998 # VirtualHost Example:
1003 #<virtualhost *:80>
1004 # ServerAdmin [email protected]
1005 # documentroot/www/docs/www.linuxidc.com
1006 # ServerName Www.linuxidc.com
1007 # errorlog Logs/www.linuxidc.com-error_log
1008 # Customlog Logs/www.linuxidc.com-access_log Common
1009 #</virtualhost>

Apache Master configuration file httpd.conf detailed

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.