Apache Service in-depth analysis

Source: Internet
Author: User

One, Apache service installation, service management and related documents!
Explains the installation, service management, configuration files and other related files of Apache services under Linux.
CentOS 6.3 (RHEL 6) Yum is integrated with Apache 2.2.15 (httpd 2.2.15)
Enable the following command to install the Apache server:
Yum Install-y httpd
Other Apache related packages:
Httpd-devel-Developing related header files
Httpd-tool-apache related tools, such as AB, htpasswd
Httpd-manual-apache Official documents
After installation, you can enable the following command to start and close the Apache server:
Service httpd Start
Service httpd Stop
Service httpd Restart
Apache also provides a number of special server directives:
Service httpd Graceful
Service httpd Graceful-stop

/etc/httpd
/etc/httpd/conf/httpd.conf-apache Master configuration file
/etc/httpd/conf.d-apache Module Configuration file
/etc/httpd/modules-apache Module File path link
Apache Default Web site root directory:/var/www/html
Apache related account: cat/etc/passwd | grep Apache
Default log file location:/var/log/httpd

Second, Apache service basic concept (DSO, MPM, etc.)
Explains some of the basic concepts of Apache services, including service processes, listening ports, MPM, and DSO.
The Apache service enables a master process and multiple child processes by default, and the child process is responsible for processing user requests. Master process as root user
While the child process runs as a lower-privileged Apache user. The number of child processes is determined by the configuration.
PS aux | grep HTTPS
Apache is a modular server, the core contains only basic functions, extension functions are implemented by different functional modules.
Use the following command to view the compiled module:
Httpd-m
Use the following command to view the modules that are statically compiled into the Apache program:
Httpd-l
Shared modules can be compiled separately via the APXS command line.
The shared module is loaded in the configuration file via LoadModule:
LoadModule Module Name Module path
Apache has introduced the MPM feature above version 2.0, which is responsible for network port binding via MPM (Multi Process Modules).
and receive processing requests.
You can determine the MPM used by Apache in the following two ways:
Httpd-l
Httpd-v

The default MPM used under Linux is Prefork, and you can choose to use worker.
Prefork are typically higher than worker performance, but use more resources.

Third, Apache process management MPM detailed (Prefork and worker)
An in-depth explanation of the MPM process management mechanism used by Apache, including Prefork and worker.
Prefork is a non-threaded, pre-derived MPM for systems that do not have a thread-safe library and need to avoid thread-compatibility issues.
Ec
Prefork processes user requests through multiple child processes, and each child process can only process one request at a time. Apache through a
The parent process (the control process) is responsible for generating child processes.
The number of child processes is dynamically adjusted based on the number of requests, but in order to avoid creating child processes when the request arrives,
Apache will pre-create some sub-processes and wait for the request to arrive.
Startservers: Created at service startup? Number of child processes
minspareservers: Minimum number of idle child processes
maxspareservers: Maximum number of idle child processes
serverlimit: Maximum value allowed for maxclients
maxclients: Maximum number of requests that are allowed to be processed concurrently
Maxrequestsperchild: The maximum number of requests that can be processed by each child process
<ifmodule prefork.c>
Startservers 8
Minspareservers 5
Maxspareservers 20
Serverlimit 256
MaxClients 256
Maxrequestsperchild 4000
</IfModule>

Iv. Overview of the Apache master configuration file-1 (Global configuration)
The contents of the Apache master configuration file are explained mainly in the first part of the Global configuration section.
The Apache master configuration file is divided into three sections by default:
Section 1:global Environment-Global configuration
Section 2: ' Main ' server configuration-Primary service config
section 3:virtual hosts-virtual host configuration
The first part of the main configuration content:
Servertokens OS
Controls the verbosity of server information in the header information that is being responded to to the client
Prod:apache
Major:server:apache/2
os:server:apache/2.0.41 (Unix)
full:server:apache/2.0.41 (Unix) php/4.2.2 mymod/1.2
ServerRoot "/ETC/HTTPD"
Specify the server location?? Directory Location
Pidfile Run/httpd.pid
Specifies the file location of the record server control process (parent process) ID
Timeout 60
Specify the time-out for the connection
KeepAlive OFF
Specifies whether the KeepAlive feature is turned on
Maxkeepaliverequests 100
Specifies the number of requests for a connection to the most incoming rows after keepalive is turned on
KeepAliveTimeout 15
Specifies the maximum time interval between two requests within a connection after opening keepalive
Listen 12.34.56.78:80
Listen 80
Specifies the end of the Apache service's default listener. Number and IP address
LoadModule Foo_module modules/mod_foo.so
Specify Apache to load those modules
Include conf.d/*.conf
Load profile information in CONF.D (module configuration file)
User Apache
Group Apache
Specify the user that the Apache child process uses

V. Overview of the Apache Master Profile-2 (primary service configuration)
To explain the Apache master configuration file, the main part is the second-main service configuration.
ServerName www.LinuxCast.net:80
Domain name
Usecanonicalname OFF
How to set the standard domain name to On,apache using servername settings. How to set to OFF, Apache will make the client pass
The host name specified by the recursive host parameter. If you are using a domain-based virtual host, then this is set to off.
DocumentRoot "/var/www/html"
Site root directory
<directory "/var/www/html" >
</Directory>
Directory-based access Control!!
<ifmodule mod_userdir.c>!
</ifmodule>!
Conditional module Configuration
DirectoryIndex index.html Index.html.var
Specify site default home page configuration
Accessfilename. htaccess
Read distributed configuration? file
<files ~ "^\.ht" >
</Files>
File-based access control
Typesconfig/etc/mime.types
Specifying MIME type files
DefaultType Text/plain
Default corresponding content type
Hostnamelookups OFF
Specifies whether domain name resolution is turned on (if enabled, the IP address will be attempted to be resolved to a domain name in the log record)
Errorlog logs/error_log!
Save error? Where is the log saved, error? Log records Apache service shipping Information!
LogLevel warn
Specify the logging level (verbosity)
Logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" combined
Set the logging format, combined indicates two more%{header}i information.
Customlog Logs/access_log combined
Setting the location and related parameters of the access log

Apache Service in-depth parsing

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.