Apache Virtual Host -------- file descriptor restriction-Linux Enterprise Application-Linux server application information. For details, see the following. When a large number of virtual hosts are used and each host uses different log files, Apache may suffer from depletion of file descriptors (sometimes called file handles. The total number of file descriptors used by Apache is as follows: one for each different error log file, one for each other log file, and 10-20 for internal use. The Unix operating system limits the number of file descriptors that each process can use. The typical upper limit is 64, but can be expanded until a large hardware limit is reached (hard-limit ).
Although Apache will try to increase the limit, this mechanism will not work if:
1. Your operating system does not provide setrlimit () system calls.
2. setrlimit (RLIMIT_NOFILE) calls cannot work properly on your system (for example, Solaris 2.3)
3. The demand for file descriptors has exceeded the hardware limit.
4. Your Operating System imposes other restrictions on file descriptors. For example, the stdio stream can only use file descriptors smaller than 256. (Solaris 2)
If you encounter such a problem, you can solve it as follows:
* Reduce the number of log files. No Specify the log file in the configuration section, but only record it in the main log file. (See the following log file for details)
* If your system is not working properly for the above 1st or 2nd reasons, you can use a script similar to the following to increase the file descriptor limit before starting Apache:
#! /Bin/sh
Ulimit-S-n 100
Exec httpd
Top
Break down log files
If you want to record the logs of multiple virtual hosts to the same log file, you may want to separate them afterwards to perform statistical analysis on the data of different virtual hosts. You can use the following methods to achieve this purpose.
First, you need to put the VM information into the log. You can use the LogFormat command and the "% v" variable to achieve this purpose. Add them at the beginning of your log format string:
LogFormat "% v % h % l % u % t \" % r \ "%> s % B" vhost
CustomLog logs/multiple_vhost_log vhost
This will create a log file using the common log format. However, a formal Virtual Host Name (the one defined in the ServerName command) is added before each record ). (See custom log format for more information)
You can use the split-logfile program to separate log files (one log file per virtual host. You will find this program in the support directory of the Apache release.
Run the program using the following command:
Split-logfile </logs/multiple_vhost_log
When this program uses a virtual host log file as a parameter, a file is created for each virtual host in the log file. Each file is named in the form of "host name. log.
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