Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Explanation of three working modes and directory attributes of Apache

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Introduction of Apache working mode

1.Apache is the most widely used and most stable open source server software for web servers today.

two。 There are many working modes. When the source package installs httpd, you can view the httpd-mpm.conf file, which is located in the extra/conf directory.

3. At present, there are two main modes:

Event mode: multiple threads in a process

Prefork mode: a process contains a thread

Worker mode: multiple threads in a process

Introduction to event working mode:

1.event is the latest working mode of Apache, which is very similar to worker mode, except that it solves the problem that thread resources are wasted during keep-alive long connections.

2.event working mode will fail when it encounters some incompatible modules and will fall back to worker mode

The 3.event working mode requires epoll support from the Linux system (Linux 2.6 +) to enable it. What needs to be added is the HTTPS connection (SSL)

4. In the event working mode, there are specialized threads to manage these keep-alive types of threads

5. When a real request comes, the thread that passes the request to the server finishes execution and allows it to release

6. In this way, a thread can handle several requests, achieving asynchronous non-blocking. This enhances request processing in high concurrency scenarios

Event parameters are explained in the httpd-mpm.conf configuration file. The following is the definition of the prefork module: StartServers 3 MinSpareThreads 75 MaxSpareThreads 250ThreadsPerChild 25 MaxRequestWorkers 400 MaxConnectionsPerChild 0 Parameter description: parameter indicates the initial number of processes when the StartServers service is started, the default minimum number of free child processes in 3MinSpare Threads, the maximum number of free child processes in default 75MaxSpare Threads, and the number of threads generated by each child process in default 250ThreadsPerChild By default, 25MaxRequestWorkers limits the maximum number of requests accessed by the client at the same time. By default, each child process of 400MaxConnectionsPerChild allows the maximum number of requests during its life cycle. If the total number of requests has reached this value, the child process will end. If set to 0, the child process will never end. Setting this value to a non-zero value can prevent memory leaks caused by running PHP. Event optimization recommendation 1. Can be debugged according to the production environment to determine the appropriate parameters 2. Optimization reference: ServerLimit 1000 StartServers 20 MinSpareThreads 25 MaxSpareThreads 1200 ThreadsPerChild 50 MaxRequestWorkers 2000 MaxC onnectionsPerChild 1000prefork Operation Mode introduction

1.prefork is a multiplexing module (MPM), which implements a process-based, pre-derived web server, which is suitable for systems without thread-safe libraries and need to avoid thread compatibility problems.

two。 It has good characteristics when each request is required to be independent of each other. If there is a problem with one request, it will not affect other requests.

3. It has a strong ability of self-regulation, and only a few configuration instructions are needed to adapt to the requirements of enterprise applications.

4. The most important thing is to set MaxClients to a number large enough to handle potential request peaks, but not too large to avoid requiring more memory than physical memory

5. A separate control process (parent process) is responsible for generating child processes, which are used to listen to requests and respond, so there is always some spare (spare) or idle child processes in memory to respond to new requests, which speeds up the response

6. The parent process usually runs as root to bind port 80, and the child process usually runs as a low-privileged user, which can be configured through the User and Group of the configuration item

7. The user running the child process must have read access to the content of the site, but must have as few permissions as possible to other resources to ensure system security.

8. No working mode is specified when compiling and installing. Prefork mode is used by default, which can be viewed with httpd-l.

The prefork parameter is explained in the httpd-mpm.conf configuration file. The following is the definition of the prefork module: StartServers 20 MinSpareServers 10 MaxSpareServers 50 MaxClients 150 MaxRequestsPerChild 0 Parameter description: parameter description: maximum number of processes created when ServerLimit starts MinSpareServers minimum idle processes MaxSpareServers maximum number of idle processes MaxClients maximum number of child processes to handle requests MaxRequestsPerChild the maximum number of requests processed by each process, reaching the number of requests The process is destroyed, and if set to 0, the child process will never end prefork tuning recommendation 1. Can be debugged according to the production environment to determine the appropriate parameters 2. Optimization reference: ServerLimit 1000 StartServers 10 MinSpareServers 10 MaxSpareServers 30 MaxClients 1000 MaxRequestsPerChild 5000worker Operation

1. The number of threads each process can have is fixed, and the server will increase or decrease the number of processes according to the load.

two。 A separate control process (parent process) is responsible for the establishment of child processes. Each child process can set up a number of ThreadsPerChild service threads and one listener thread, which listens for access requests and passes them to the service thread for processing and response

3.Apache always maintains a spare or idle pool of service threads, and the client can be serviced without waiting for a new thread or process to be established.

4. The parent process is usually started as root to bind port 80; subsequently, Apache sets up child processes and threads with lower privileges

The 5.User and Group directives are used to configure the running user of the Apache child process. The child process should have read access to the content of the web page, but should restrict the permission as much as possible

Parameter description: the parameter indicates the maximum number of ServerLimit processes. The default value is the maximum number of threads per child process of "16" ThreadL imit. The default value is the number of child processes established when the "64" StartServers server starts. The default value is the maximum number of access requests allowed by "3" MaxClients (maximum number of threads) MinSpare Threads minimum number of idle threads, and the default value is "75" MaxSpare Threads to set the maximum number of idle threads. The default value is the number of resident threads of execution established by each child process of the "250th" ThreadsPerChild. The default value is 25MaxRequestsPerChild to set the maximum number of requests that each child process is allowed to serve during its lifetime. Set to "0" and the child process will never end the Apache directory property

1. The permission settings of the directory use and

< /Directory >

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report