Httpd. conf
Apache main configuration file:/etc/httpd/conf/httpd. conf
Default site home directory:/var/www/html/
The configuration information of the Apache server is stored in the master configuration file/etc/httpd/conf/httpd. in conf, there are a lot of content in this file, and a total of 1009 lines are counted using the wc command, most of which are comments starting.
[Root @ justin ~] # Wc-l/etc/httpd/conf/httpd. conf
1009/etc/httpd/conf/httpd. conf
[Root @ justin ~] #
The configuration file consists of three parts:
[Root @ justin ~] # Grep '\ <Section \>'/etc/httpd/conf/httpd. conf-n
33: ### Section 1: Global Environment
245: ### Section 2: 'main' server configuration
973: ### Section 3: Virtual Hosts
[Root @ justin ~] #
1) Global Environment --- Global Environment configuration, which determines the Global parameters of the Apache server
2) Main server configuration --- Main service configuration, which is equivalent to the default Web site in Apache. If there is only one site on our server, you only need to configure it here.
3) Virtual Hosts --- Virtual host. The Virtual host cannot coexist with the Main Server master Server. When the Virtual host is enabled, the Main Server cannot be used.
--------------------------------------------------------------------------------
1) Global Environment
44 ServerTokens OS
Whether the server operating system name is displayed when an error page appears. ServerTokens Prod is not displayed.
57 ServerRoot "/etc/httpd"
Used to specify the Apache running directory. After the service is started, the directory is automatically changed to the current directory.
65 PidFile run/httpd. pid
Record the pid Number of the httpd daemon. This is the method used by the system to identify a process. There can be multiple httpd processes in the system, but the process corresponding to this PID is another parent process.
70 Timeout 60
Time when the server and client are disconnected
76 KeepAlive Off
Whether to connect continuously (because three handshakes are required for each connection. If the access volume is small, it is recommended to enable this option. If the access volume of the website is large, it is better to disable this option). Modify KeepAlive On to allow procedural online connection.
83 MaxKeepAliveRequests 100
The maximum number of requests for a connection.
89 KeepAliveTimeout 15
Time Before disconnection
102 <IfModule prefork. c>
103 StartServers 8
104 MinSpareServers 5
105 MaxSpareServers 20
106 ServerLimit 256
107 MaxClients 256
108 MaxRequestsPerChild 4000
109 </IfModule>
The system's default module indicates that one process is started for each access (that is, when multiple connections share one process, only one service can be obtained at a time ).
When StartServer starts the service, it starts eight processes. The minimum number of idle processes is 5, and the maximum number of idle processes is 20.
MaxClient limits the maximum number of client connection requests that exceed the same time point to enter the waiting queue.
MaxRequestsPerChild: Maximum number of requests allowed for each process during the lifetime. 0 indicates that the service will never end.
118 <IfModule worker. c>
119 StartServers 4
120 MaxClients 300
121 MinSpareThreads 25
122 MaxSpareThreads 75
123 ThreadsPerChild 25
124 MaxRequestsPerChild 0
125 </IfModule>
Configure thread access for Apache, that is, start a thread for each WEB service access, so that the memory usage is relatively small.
The ServerLimit server allows you to configure the maximum number of processes.
ThreadLimit the maximum number of threads that each sub-process may configure
StartServers starts two httpd processes,
MaxClients can initiate up to 250 access requests at the same time. The number of requests that exceed the limit must wait in the queue. The size is determined by the product of ServerLimit and ThreadsPerChild.
ThreadsPerChild: number of resident execution threads during the survival of each sub-process. After the sub-thread is established, it will not increase
MaxRequestsPerChild: Maximum number of threads started by each process. If the maximum number of threads is reached, the process will end. If it is set to 0, the sub-thread will never end.
136 Listen 80
The listening port. If multiple NICs exist, all NICs are listened to by default.
123 150 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
Loaded configuration file
242 User apache
243 Group apache
After the service is started, the transformed identity is usually root when the service is started, and then the identity is changed to increase system security.
2) Main server configuration
262 ServerAdmin root @ localhost
Administrator's mailbox
276 # ServerName www.example.com: 80
By default, this parameter is not required. The server obtains its own name through the name resolution process, but if there is a problem with the resolution (such as incorrect reverse resolution) or no DNS name, you can also specify an IP address here. If this is incorrect, the server cannot start properly. When Apache is started, the system prompts that httpd: apr_sockaddr_info_get () failed forjustin httpd: cocould not reliably determine the server's fully qualified domain name, using 127.0.0.1forServerName, the solution is to enable this item to change www.example.com: 80 to your own domain name or directly change it to localhost.
1 285 UseCanonicalName Off
If the client provides the host name and port, Apache uses the information provided by the client to build a self-Reference URL. These values are the same as those used to implement domain name-based virtual hosts and are available for the same client. The CGI variables SERVER_NAME and SERVER_PORT are also constructed by the values provided by the client.
292 DocumentRoot "/var/www/html"
Directory for storing webpage files
302 <Directory/>
303 Options FollowSymLinks
304 AllowOverride None
305 </Directory>
Setting a permission for 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>
For setting a permission for the/var/www/html directory, Indexes in options indicates that when the webpage does not exist, the Indexes are allowed to display files in the directory and whether FollowSymLinks allows access to symbolic link files. Some Options include whether to use cgi for the ExecCGI table. For example, Options allow des ExecCGI FollowSymLinks indicates that the server is allowed to execute CGI and SSI, And the directory cannot be listed. SymLinksOwnerMatch indicates that access is allowed only when the file linked by the symbol is owned by the same user as the target file. AllowOverrideNone indicates that the access control file in this directory is not allowed to change the configuration here. This also means that you do not need to view the access control file in this directory. If you change it to AllowOverride All, it indicates that. htaccess is allowed. The default option is next to the Order for page access control. For example, allow and deny are deny by default. Allowfromall indicates that all users are allowed, by combining with the previous item, you can control Website access control.
<IfModule mod_userdir.c>
366 UserDir disabled
375 </IfModule>
Whether to allow users to access their home directories is not allowed by default
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 # <limitaskt get post options>
389 # Order deny, allow
390 # Deny from all
391 # </limit0000t>
392 # </Directory>
If you are allowed to access webpage files in your home directory, cancel the preceding comments and modify them.
402 DirectoryIndex index.html. var
Specifies the name of the main page of the target webpage. the first page is named index.html.
409 AccessFileName. htaccess
Defines the access control file name in each directory. The default value is. htaccess.
415 <Files ~ "^ \. Ht">
416 Order allow, deny
417 Deny from all
418 Satisfy All
419 </Files>
Control and prevent web users from viewing. htpasswd and. htaccess files
425 TypesConfig/etc/mime. types
Used to set the file name for storing data of different MIME types
436 DefaultType text/plain
Default webpage type
443 <IfModule mod_mime_magic.c>
444 # MIMEMagicFile/usr/share/magic. mime
445 MIMEMagicFile conf/magic
446 </IfModule>
Module used to determine the real MIME type of a file
456 HostnameLookups Off
When this function is enabled, the host name is recorded when logs are logged. This requires the server to reverse resolve the domain name and increase the server load. It is generally not recommended to enable this function.
466 # EnableMMAP off
Whether to allow memory ing: If httpd needs to read the content of a file during transmission, can it use memory ing. If it is on, memory ing is used if the operating system supports it. In some multi-core processor systems, this may reduce performance. If this function is enabled on the DocumentRoot mounted to NFS, httpd may crash due to segmentation.
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 that does not need to access data in the file (for example, sending a static file content), if the operating system supports, apache uses sendfile to directly send the file content to the client without reading the file.
1 484 ErrorLog logs/error_log
Location where error logs are stored
491 LogLevel warn
Apache Log Level
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
500 LogFormat "% {User-agent} I" agent
Defines the log format and uses different codes for representation.
513 # CustomLog logs/access_log common
526 CustomLog logs/access_log combined
Indicates the location of the log record, where the relative path is used. Therefore, ServerRoot must point out that the log location is stored in/etc/httpd/logs.
536 ServerSignature On
Determines whether apache version information is prompted when the requested webpage does not exist or is incorrect.
551 Alias/icons/"/var/www/icons /"
Define files not under DocumentRoot and map them to the root directory of the webpage. This is also a way to access other directories, but remember to add "/" to the directory when declaring it "/"
553 <Directory "/var/www/icons">
554 Options Indexes MultiViews FollowSymLinks
555 AllowOverride None
556 Order allow, deny
557 Allow from all
558 </Directory>
Define the permission for/var/www/icons/. Modify to Options MultiViews FollowSymLinks to indicate that the tree directory structure is not displayed on the browser.
563 <IfModule mod_dav_fs.c>
564 # Location of the WebDAV lock database.
565 DAVLockDB/var/lib/dav/lockdb
566 </IfModule>
Management of mod_dav_fs.c Module
576 ScriptAlias/cgi-bin/"/var/www/cgi-bin /"
The Alias for the CGI Module is 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>
Manage the/var/www/cgi-bin folder in the same way as above
# Redirect old-URI new-URL
The Redirect parameter is used to override the URL. When the browser accesses a nonexistent resource on the server, the server returns a new URL to the browser, telling the browser to obtain the resource from the URL. This is mainly used to change the location of a document that originally exists on the server, and you need to be able to access the original webpage using the old URL.
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 there is no index file in the Directory and the server permits the display of the directory file list, the file list in this directory is displayed. To make the file list understandable, not just a simple list, these parameters are required. If the IndexOptionsFancyIndexing option is used, the server can reference different icons for different files. If not, use DefaultIcon to define the default icon. Similarly, using AddDescription can be described for different types of documents.
709 AddLanguage ca. ca
......
734 AddLanguage zh-TW. zh-tw
Add language
743 export agepriority en ca cs da de el eo es et fr hr it ja ko ltz nl nn no pl pt-BR ru sv zh-CN zh-TW
Languages supported by Apache
759 adddefacharcharset UTF-8
Supported languages by default
765 # AddType application/x-tar. tgz
If you want to add such a line for parsing php
773 # AddEncoding x-compress. Z
774 # AddEncoding x-gzip. gz. tgz
Support for files ending with .zand .gz. tgz
779 AddType application/x-compress. Z
780 AddType application/x-gzip. gz. tgz
Add applications for the preceding two files
796 # AddHandler cgi-script. cgi
Modify to: AddHandler cgi-script. cgi. pl indicates that CGI scripts with the extension. pl can be run.
816 AddType text/html. shtml
817 AddOutputFilter between des. shtml
Add the dynamic processing type as server-parsed. The server analyzes the tags in the webpage in advance and changes the tags to the correct HTML tags.
833 # ErrorDocument 404/missing.html
Return to the missing.html page when the server returns a error message.
855 Alias/error/"/var/www/error /"
Assign alias
857 <IfModule mod_negotiation.c>
858 <IfModule mod_include.c>
859 <Directory "/var/www/error">
860 AllowOverride None
861 Options IncludesNoExec
862 AddOutputFilter between des html
863 AddHandler type-map var
864 Order allow, deny
865 Allow from all
866 define agepriority en es de fr
867 ForceLanguagePriority Prefer Fallback
868 </Directory>
Permissions and operations on/var/www/error webpages
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 earlier browsers and support the features of new browsers.
3) Virtual Hosts
990 # NameVirtualHost *: 80
If you enable a VM, you must remove the preceding comments and the content in the second part can appear in each VM.
998 # VirtualHost example:
1003 # <VirtualHost *: 80>
1004 # ServerAdmin webmaster@www.bkjia.com
1005 # DocumentRoot/www/docs/www.bkjia.com
1006 # ServerName www.bkjia.com
1007 # ErrorLog logs/www.bkjia.com-error_log
1008 # CustomLog logs/www.bkjia.com-access_log common
1009 # </VirtualHost>
Www.bkjia.com is replaced with your website
------------------------------------- I am a split line -------------------------------------
How to enable Apache Rewrite in Ubuntu
Key points after upgrading Apache 14.04 to 2.2 in Ubuntu 2.4
Install the LAMP \ Vsftpd \ Webmin \ phpMyAdmin service and settings in Ubuntu 13.04
Compile and install LAMP in CentOS 5.9 (Apache 2.2.44 + MySQL 5.6.10 + PHP 5.4.12)
Source code for Web server architecture in RedHat 5.4 build the LAMP environment and application PHPWind
Build a WEB Server Linux + Apache + MySQL + PHP in the LAMP source code Environment
This article permanently updates the link address: