How to switch apache prefork and worker mode

  
 

The Apache HTTP server is designed to be a powerful and flexible server that can work on multiple platforms and different environments. Different platforms and different environments often have different needs, or different approaches are used to achieve the same best results. Apache is well adapted to a large number of different environments with its modular design. This design allows webmasters to determine different additional features of the server by loading different modules at compile time and runtime.

Apache 2.0 extends this modular design to the basic functionality of web servers. This version comes with a Multiprocessing Module (MPM) option to handle network port bindings, accept requests, and assign child processes to handle these requests. For example, if you need better scalability, you can choose a threaded MPM like a worker or event, and you need better stability and compatibility to adapt to some old software can use prefork.

In the main version of Redhat Linux as4, the apache version is httpd-2.0.5x, the default is prefork mode, mainly considering the stability reasons. To switch to worker mode, you need to log in to linux, do the following:

Enter /usr/sbin directory cd /usr/sbin

Rename the current prefork mode startup file to mv httpd Httpd.prefork

Rename the startup file of the worker mode to mv httpd.worker httpd

Modify the configuration file vi /etc/httpd/conf/httpd.conf and find the following section inside, which can be modified appropriately. Parameters such as load: <IfModule worker.c>StartServers 2MaxClients 150MinSpareThreads 25MaxSpareThreads 75ThreadsPerChild 25MaxRequestsPerChild 0</IfModule>

Restart the service /etc/init.d/httpd restart

Worker mode starts apache2

Note that you may encounter errors here:

Apache is running a threaded MPM, but your PHP
Module is not compiled to be threadsafe. You need To recompile PHP
. Pre-configuration failed! The solution is to comment out the line of code starting with LoadModule in the /etc/httpd/conf.d/php.conf file. --------------------------

Note: For stability and security reasons, it is not recommended to change the operation mode of apache2. Using the system default prefork can be a lot of other php modules can not work in the worker mode, such as redhat linux comes with php can not support thread safety, so it is best not to switch the working mode. ========================================================== /init.d/httpd stop[root@web ~]# which apachectl/usr/sbin/apachectl[root@web ~]# which httpd/usr/sbin/httpd[root@web ~]# cd /usr/sbin/[root@web ~]# mv httpd httpd.prefork# mv httpd.worker httpd# httpd -k start

Copyright © Windows knowledge All Rights Reserved