Apache Website Services

Source: Internet
Author: User

apache:http://mirror.bit.edu.cn/apache/httpd/
Related software: HTTP://MIRROR.BJTU.EDU.CN/APACHE/APR/APR
Http://mirror.bjtu.edu.cn/apache/apr/apr-util
=============apache Introduction: Process technology, high resource consumption, but stable;

MPM (Multi process Moudles): multi-processing module;
Apache Working mode:
Process Pool (prefork): Suitable for dynamic pages, always prepare the process in advance waiting for the visitor, a process corresponding to a Web access request;
Thread pool (worker,event): Suitable for static pages, such as first open 5 processes, each process opened 100 threads, a thread to receive a Web access request;

httpd------->prefork----> Default
Httpd.worker------->worker
Httpd.event-------->event
How can I change the MPM mode of operation if I use the simplified installation of Apache?

=================lamp Platform Overview:

Processes and Threads in =========apache:

1 "Installing Apache Software:
RPM and Yum Installation:
1> Yum Install httpd
Service httpd Restart

Start the service script------"Run/USR/SBIN/HTTPD----" Call/etc/httpd/conf/httpd.conf;

The name of the program that truly provides the httpd service;

2> Source Installation:
= = Download Package:
http://mirror.bit.edu.cn/apache/httpd/
Http://mirror.bjtu.edu.cn/apache/apr/apr
Http://mirror.bjtu.edu.cn/apache/apr/apr-util

= = Install software:
Yum-y install gcc autoconf automake make pcre pcre-devel OpenSSL openssl-devel

Apr
./configure
Make && make install
Apr-util:
./configure--WITH-APR=/USR/LOCAL/APR
Make && make install
httpd
./configure--prefix=/usr/local/apache--enable-so--enable-ssl--enable-rewrite--with-mpm=worker--with-suexec-bin --with-apr=/usr/local/apr
Make && make install
You can view all the options supported by the script through the./configure--help command:
--prefix specifying the installation home directory for Apache httpd programs
--enable-so turn on the modular function, support DSO (dynamic shared object)
--ENABLE-SSL supports SSL encryption
--enable-rewrite Support for address rewriting
--WITH-MPM setting Apache working mode
--with-suexec-bin Support Suid,sgid
--WITH-APR specifying the APR program absolute path

2. Modify the configuration file:
Master configuration file:/etc/httpd/conf/httpd.conf:
Simple configuration:

The above hint indicates that there is no standard domain name, you need to specify:
SERVERNAME:WWW.CHW.COM:80-----276 Lines "Open the configuration, remove the comments, and then modify;

Profile Details Resolution: The main configuration file for Apache services consists of instructions and containers, container use < container name > start, to </container name > end, container directives are generally only valid within the container:
1>severroot directive:
Set the installation home directory of the software, if it is installed by the source code, the default path is/usr/local/apache2;
2>listen directive:
Set the server listening IP and port number, the default listener server all IP address 80 port, the syntax format is: LISTEN[IP address:] Port [Protocol], where the IP address and protocol is optional, the default listener all IP, using the TCP protocol, a configuration Multiple ports can be opened using the listen instruction multiple times;
3>loadmodule directive:
If you want Apache to dynamically load the module, you need to compile Apache by enable-so the Mod_so statically compiled into the Apache core module, the role of this directive is to load the module, the syntax format is: LoadModule module module file name , wherein the module files are generally located in the modules directory under the ServerRoot directory;
4>loadfile directive:
The function is similar to the above instruction, except that the latter can load the module file of the modules directory through an absolute path;

              5>serveradmin directives:
  When a Web site fails, it is necessary to provide the customer with a mail address that can help resolve the problem Address, the role of the serveradmin directive is to provide such an e-mail address;
6>servername directive:
Sets the host name and port of the server native, which is important for the redirection of the URL address;
7>docume NTROOT directive:
Set the Web service team client open visible document root directory, that is, the root directory of Client access Web site;
8>errorlog directive:
     Locate server error The location of the error log, using a relative path by default;
9>errorlogformat directive:
Sets the format of the fault log;
10>customlog directive:
    Sets the client's access log file name and format, in the format: Customlog file name format,
11>logformat directive:
   describes user log file format, typically we create a log format for this instruction Name, and then call the log format alias through the Customlog Directive;

               12>include directives:
  allow Apache to load additional configuration files in the master configuration file;
        13>options directive:
Sets options for a specific directory, options can be set to none, means no additional functionality is enabled, or you can use the following common options:
All: Open all options except multiviews;
EXECCGI: Allows all CGI scripts in the options specified directory to be executed,
FollowSymLinks: Allows options to be specified in the directory to link files or directories outside the directory;
Indexes: If In the options directory corresponding to the URL cannot find the DirectoryIndex specified home page document, the server will be the current directory of all files indexed;
14>order directive:
Controls the default access state and the order of allow and deny , if you use Order Deny,allow, first check the Deny, then check allow, when the rejection and allow conflict, allow priority, the default rule is                   If you use order Allow, deny, the first check allows, then the deny, and when the permit conflicts with the deny, the default rule is deny;

                            Specific cases:
Order Deny,allow
deny from all;

Order Allow,deny
Enable from all allows

Order Allow,deny
allow from 192.168.1.2 to deny all except this IP;

Order Allow,den           Y
Allow from 192.168.1.2
to deny everyone access;

Order Deny,allow
Deny from any
allow from 192.168.1.2  to deny all except this IP;

                       15>ifdefine container:
This container seal The instruction is only processed when Apache is started, and the test condition needs to be defined through-D when Apache is started:
instance:
Service httpd-d usecache-d MemCache Res         Tart

<ifdefine memcache>
LoadModule mem_cache_module modules/mod_mem_cache.so
</ifdefine>

<ifdefine usecache>
LoadModule cache_module Modules/mod_cache. So
</IfDefine>     

16>ifmodule Container:
This container encapsulates instructions that will only be processed when the condition is met, depending on whether the specified module has been loaded to determine whether the condition is satisfied;
Case:
<ifmodule unixd_module>
User Daemon
Group Daemon
</IfModule>
17>directory Container:
The intra-container directive applies only to specific file system directories, subdirectories, and content under the directory;
18><directorymatch>
This instruction is similar to the above instruction, but can be directly used to match the regular expression, without the use of the ~ symbol;
19>files Container:
The instructions within the container apply only to a specific file, which can be used to match regular expressions;
20>filesmatch Container:
Use only regular expressions to match the required files;
21>location Container:
The directives defined within the container are valid only for a specific URL, in the syntax format: <location url-path| Url> </location> If you need to use regular expressions, you can use the ~ symbol to match;

22>LOCATIONMATHCH Containers and VirtualHost containers:
Using only regular expressions to match URLs is equivalent to using the ~ symbol matching location;

============= Virtual host application case:
Virtual host is a server running multiple Web services at the same time, the Apache service support domain-based and IP-based virtual host type, but more often we prefer the domain-based virtual host, the server can access htttp based on the client's head information to achieve the separation of the site analysis, Clients can use different domain names to access server resources located at the same IP address;

1. Modify the master configuration file:
The include conf/extra/httpd-vhosts.conf statement in the master configuration file is turned on, and the include directive reads the contents of the secondary configuration file as part of the primary profile, and the ports for the two virtual hosts should be different. Therefore, the main configuration file should listen to two ports;

2. Modify the secondary configuration file:

3 "Create the respective page root for two different virtual hosts:
When visiting these two sites, if there is no legitimate DNS server, you can modify the Hosts file for domain name resolution, if you need to make a virtual host based on IP address, just modify the * to a fixed IP address, multiple virtual hosts need to use multiple virtualhost encapsulation;

# prefork MPM
# Startservers:number of server processes to start
# minspareservers:minimum number of server processes which is kept spare
# maxspareservers:maximum number of server processes which is kept spare
# Serverlimit:maximum value for maxclients for the lifetime of the server
# maxclients:maximum number of server processes allowed to start
# maxrequestsperchild:maximum number of requests a server process serves
<ifmodule prefork.c>
Startservers 8
Minspareservers 5
Maxspareservers 20
Serverlimit 256
MaxClients 256
Maxrequestsperchild 4000
</IfModule>

# worker MPM
# startservers:initial number of server processes to start
# maxclients:maximum number of simultaneous client connections
# minsparethreads:minimum number of worker threads which is kept spare
# maxsparethreads:maximum number of worker threads which is kept spare
# threadsperchild:constant number of worker threads in each server process
# maxrequestsperchild:maximum number of requests a server process serves
<ifmodule worker.c>
Startservers 4
MaxClients 300
Minsparethreads 25
Maxsparethreads 75
Threadsperchild 25
Maxrequestsperchild 0
</IfModule>
When the above value assignment is not at that time, refresh the service when the reminder?

Attention:
Linux kernel By default, the number of files that a process can open is 1024;

You can use the command to modify this value:
Ulimit-n 25,535 can only be temporarily effective;
By default, Apache compiles which modules come in:

3. Start the service, configure firewall rules, or turn off the firewall:
Service httpd Restart
Iptables-i input-p TCP--dport 80-j ACCEPT
Service Iptables Save

Apache Website Services

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.