Linux configuration Apache2 experience summary

  

Apache originally refers to the http server program, and later became the organization name of the program, so the original program name is set to httpd, and after the 2.0 version is called apache2. Currently on the windows is also called httpd, on the debian/ubuntu/linux mint series of Linux, the program name is apache2. So the online information on httpd is partially applicable to apache2. The official website itself also uses the httpd statement, which can be understood as httpd is the product name, apache2 executable program name.

Use sudo apt-get install apache2 to install, my linux mint is installed version 2.2, Ubuntu13 is installed version 2.4, there is a little difference between the two. The official guidance document says what to do from 2.2 to 2.4. Http://httpd.apache.org/docs/2.4/upgrading.html. The most direct for the user is the difference in the number of modules and the name, and the location of the configuration file.

Change the website root directory to the user partition, you can avoid root permissions for modifying files. Method:

Version 2.2:

/etc/apache2/sites-available/default Modify the DocumentRoot and modify the Directory tag corresponding to the original path (default is /var/www), ie I have to change two places. Do not add /at the end of DocumentRoot, and add /to the Directory tag.

Version 2.4:

/etc/apache2/sites-available/000-default.conf Modify DocumentRoot,

/etc/apache2/apache2.conf Modify the corresponding Directory Tag

After modifying any settings, restart the service with the command sudo service apache2 restart. Reprint please indicate the source: http://blog.csdn.net/hursing

/etc/apache2/envvars is the parameter configuration file of the apache program, including the log path, the user name used by the program. The default log location: /var/log/apache2/has error log error.log and access log access.log. These configurations will be exported, service apache2 will source envvars file before running. If you run apache2 manually, you should source it yourself, otherwise some parameters will not be set.

Because apache2 is under /usr/bin/, the command line can use the apache2 command in any path. Apache2 -h will list the available commands. Useful:

-v View version

-V View compile time settings

-l View modules integrated at compile time

-L View Available configuration file directives

-t Check all configuration files for syntax errors

/etc/apache2/mods-available/indicates available modules, load suffix to store module paths, conf The suffix indicates the configuration of the module.

/etc/apache2/mods-enabled/indicates the enabled modules. The main configuration file apache2.conf will reference all files in this directory. This directory is all soft links, which can be seen with ls -l. Soft linking the files under /etc/apache2/mods-available/to /etc/apache2/mods-enabled/will enable the corresponding module.

The IfModule xxx tag in the configuration file indicates that the xxx module is enabled to add the parameters inside.

apache2 has multiple concurrent processing models MPM, which can be viewed at http://httpd.apache.org/docs /current/mpm.htmlLearn more. The default is the perfork model. Each concurrent processor is in a separate process, and its configuration parameters directly affect the performance of concurrent processing.

Version 2.2:

Open /etc/apache2/apache2.conf and find the <IfModule mpm_prefork_module> tag

How many server processes are started when StartServers starts the program MinSpareServers is minimal Number of free servers MaxSpareServers Maximum number of free servers MaxRequestsPerChild The maximum number of requests per server. Exit when you reach, to avoid memory leaks. Set to 0 to be unlimited.

Version 2.4:

Modify /etc/apache2/mods-enabled/mpm_perfork.conf, one parameter more than 2.2. MaxRequestWorkers, the maximum number of servers. If this number wants to fill more than 256, then add a parameter MaxClients xxx. Http://httpd.apache.org/docs/current/mod/mpm_common.html has more to introduce.

The above can be commanded by ps -ef |  Grep apache2 |  Wc -l knows that there are currently several processes running. (actually the number -2, because it will count the command itself and the service main process)

The parameters in apache2.conf belong to the core module, these 4 commonly used:

Timeout timeout KeepAlive On/Off Turns on or off KeepAlive MaxKeepAliveRequests Maximum number of KeepAlive connections KeepAliveTimeout Maximum KeepAlive time, timeout will close the connection

Copyright © Windows knowledge All Rights Reserved