Web Service (2) httpd configuration parameters

Source: Internet
Author: User

The previous Web Service (I) HTTP basic detailed introduction of the http basic and httpd installation (SEE); this detailed introduction of part of the httpd-2.2 configuration parameters

CentOS 6.5 compile and install httpd-2.4.7

1. configuration file and basic format


Configuration File Path:/etc/httpd/conf/httpd. conf

Configuration Parameter Value

1. The configuration command is case-insensitive, but the value may be case-sensitive.

2. Some commands can be repeated multiple times.

Configuration File Format:

1. Global Configuration

2. Host Configuration: used to provide only one site

3. Virtual Host: used to provide multiple sites (and the host configuration cannot take effect at the same time)

Configuration File Syntax test: {service httpd configtest | httpd-t}

Ii. Detailed Configuration

1. listening socket

# Configuration file example

# Listen 12.34.56.78: 80

Listen 80

Listen 8080.

Listen 192.168.1.110: 8082


This command can appear multiple times. It is used to specify multiple listening sockets:

[Linux] # httpd-t

Syntax OK

[Linux] # service httpd reload

Reloading httpd:

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

[Linux] # ss-tnl

State Recv-Q Send-Q Local Address: Port Peer Address: Port

LISTEN 0 128: 111 :::*

LISTEN 0 128 *: 111 *:*

LISTEN 0 128: 8080 :::*

LISTEN 0 128: 80 :::*

LISTEN 0 128 192.168.1.186: 8082 *:*

2. Configure to use Keep Alive

# KeepAlive: Whether or not to allow persistent connections (more

# One request per connection). Set to "Off" to deactivate.

#

# KeepAlive On

KeepAlive Off

MaxKeepAliveRequests 100 # maximum number of persistent connection requests

KeepAliveTimeout 15 # timeout

3. Multi-Channel Processing Module MPM


View the default modules

[Linux] # httpd-l

Compiled in modules:

Core. c

Prefork. c # enable the prefork module by default

Http_core.c

Mod_so.c

[Linux] #

# To enable the worker module, change the configuration file.

[Linux] # vi/etc/sysconfig/httpd

# HTTPD =/usr/sbin/httpd. worker # enable this option and restart httpd


Configuration module information

[Linux] # vi/etc/httpd/conf/httpd. conf

# Prefork MPM

# StartServers: number of server processes to start

# MinSpareServers: minimum number of server processes which are kept spare

# MaxSpareServers: maximum number of server processes which are kept spare

# ServerLimit: maximum value for MaxClients for the lifetime of the server

# MaxClients: maximum number of server processes allowed to start

# MaxRequestsPerChild: maximum number of requests a server process serves

The prefork has good stability. A thread crashes without affecting other threads.

<IfModule prefork. c> determine whether the prefork module exists

StartServers 8 default number of worker processes started; does not contain the master Process

MinSpareServers 5 minimum number of idle Processes

MaxSpareServers 20 Max number of idle Processes

ServerLimit 256 maximum number of active processes

Maximum number of requests allowed by MaxClients 256

MaxRequestsPerChild 4000 maximum number of requests that each sub-process can provide during its lifecycle

</IfModule>

# Worker MPM

# StartServers: initial number of server processes to start

# MaxClients: maximum number of simultaneous client connections

# MinSpareThreads: minimum number of worker threads which are kept spare

# MaxSpareThreads: maximum number of worker threads which are kept spare

# ThreadsPerChild: constant number of worker threads in each server process

# MaxRequestsPerChild: maximum number of requests a server process serves

Multiple worker processes; a process crash will affect other threads under it

<IfModule worker. c> determine whether the worker module exists

Number of child processes started by StartServers 4

MaxClients 300 maximum number of concurrent requests

MinSpareThreads 25 minimum number of Idle threads

MaxSpareThreads 75 maximum number of Idle threads

ThreadsPerChild 25 Number of threads that can be generated by each sub-process

MaxRequestsPerChild 0: Maximum number of requests that each sub-process can provide during the lifecycle. 0 indicates that no limit is imposed.

</IfModule>


4. Loading Method of the DSO Module

LoadModule module_name/path/to/module

The relative path and absolute path can be used; the relative path is the location defined by ServerRoot;

After the change, the service httpd reload takes effect.

# 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

#

#

[Linux] # httpd-M # You can view all the Loading modules of the system.

Loaded Modules:

Core_module (static)

Mpm_prefork_module (static)

Http_module (static)

So_module (static)

Auth_basic_module (shared)

Auth_digest_module (shared)

Authn_file_module (shared)

Authn_alias_module (shared)

5. Configure the site root directory and page properties

# DocumentRoot: The directory out of which you will serve your

# Events. By default, all requests are taken from this directory,

# Symbolic links and aliases may be used to point to other locations.

#

DocumentRoot "/var/www/html"

DocumentRoot "/path/to/somewhere (site path)" # format

# The Options directive is both complicated and important. Please see detailed descriptions of The configurations of The following sites

# Http://httpd.apache.org/docs/2.2/mod/core.html#options

# For more information.

#

<Directory "/var/www/html"> # page access attributes

#

#

Options Indexes FollowSymLinks

#

#

#

If the default page is missing for Indexes, all files in the directory are returned to the user in the list.

FollowSymLinks allows the followers to link to the original file; dangerous

None

All Enabled

ExecCGI: whether to allow the use of mod_cgi module to execute CGI scripts

Whether the mod_include module can be used to implement server-side inclusion (SSI)

MultiViews allows the use of mod_negotiation for content negotiation

SymLinksIfOwnerMatch: the main group of the linked file and the owner Group of the original file are the same; the original file pointed to by the symbolic link is allowed.

#

#

# AllowOverride controls what directives may be placed in. htaccess files.

# It can be "All", "None", or any combination of the keywords:

# Options FileInfo AuthConfig Limit

Host-Based Access Control

#

#

AllowOverride None indicates whether the following control mechanisms are disabled; None indicates not disabled

#

# Controls who can get stuff from this server.

#

# Allow allowed; deny not allowed

Order allow, deny # deny by default; deny if no allow exists; multiple records can be written; top-down matching

Allow from all format: from IP

Deny

# If both of them match or both of them do not match, the latter prevails. Otherwise, the matching prevails.

</Directory>

# Optimal Match: Find the minimum entries from the list that can match the visitor's address for the final effect.

# Detailed reference http://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#allow

6. Define the default homepage

# The index.html. var file (a type-map) is used to deliver content-

# Negotiated documents. The MultiViews Option can be used for

# Same purpose, but it is much slower.

#

DirectoryIndex index.html. var # search from left to right

7. user directory

# The path to the end user account 'public _ html 'directory must be

# Accessible to the webserver userid. This usually means that ~ Userid

Permission description

# Must have permissions of 711 ,~ Userid/public_html must have permissions

# Of 755, and documents contained therein must be world-readable.

# The client will only receive a "403 Forbidden" message.

#

# See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden

#

<IfModule mod_userdir.c>

#

# UserDir is disabled by default since it can confirm the presence

# Of a username on the system (depending on home directory

# Permissions ).

#

UserDir disabled

Disabled

UserDir public_html: name of the directory under the user's home directory. All files in this directory can be accessed through the aforementioned access path. the user's home directory gives the user running the httpd process the execution permission;

#

# To enable requests /~ User/to serve the user's public_html

# Directory, remove the "UserDir disabled" line above, and uncomment

# The following line instead:

#

# UserDir public_html

</IfModule>

  • 1
  • 2
  • Next Page

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.