Apache httpd installation and configuration files and their descriptions

Source: Internet
Author: User

A Patchy Server = Apache American gunship

ASF: Apache Software Foundation

Tomcat

Hadoop: Thousands of computers can be combined to complete a task

www.apache.org

Apache was optimized by httpd.

httpd

Web Server, open source

Version: 2.2, 2.4,2.0,1.3

Apache Features:

Create a process beforehand

Create the right process on-demand maintenance

Modular design, the core is relatively small, a variety of functions are added module (including PHP)

Support Run configuration, support individual compile module

Support multiple ways of virtual host configuration

Virtual Host:

The physical server has only one

Web programs also have only one

But can serve many different sites.

Virtual Host:

IP-based virtual host

Port-based virtual host

Domain-based virtual host

#############################

Support for HTTPS protocol

Support user authentication

Support for IP-or host-name-based ACLs

Support for per-Directory access control

Support for URL rewriting

##############################

Installation: source code compilation and installation must be mastered

RPM Package

Source code Compilation

1, Httpd:selinux (let it in advance to permssive,disabled)

Method: Getenforce Look at the return value if it is inforcing

Execute Setenforce 0 for a temporary shutdown

Or:

Perform vim/etc/sysconfig/selinux =disabled permanent shutdown

2, only need to install httpd

Process in:

/USR/SBIN/HTTPD (Mpm:prefork)

Service script:

/etc/rc.d/init.d/httpd

Port: (80/TCP), (SSL:443/TCP)

Working root directory: equivalent to the program installation directory

/etc/httpd

Master configuration file:

/etc/httpd/conf/httpd.conf

/etc/http/conf.d/*.conf

Module directory:

/etc/httpd/modules

Log directory:

/etc/httpd/logs--->/var/log/httpd

There are two types of log files, access log access_log, error log : Err_log

Pages that respond to user access are stored in::

/var/www/

HTML: Static page

Cgi-bin: Dynamic page

CGI: Enables a Web server to launch another application to handle dynamic content when necessary

Client-to-httpd (index.cgi)-initiates a process that is associated with the CGI program language index.cgi--and httpd--Client


When the client requests a dynamic content from the server, httpd initiates a process processing index.cgi that is related to the CGI programming language, and then sends the HTTPD, httpd the message and sends it to the client.


but how to solve high concurrent multiple users to access multiple dynamic pages:

Let the Web server and the dynamic application server process combine; they both create a lot of idle child processes, and when someone initiates a dynamic request, the Web server simply needs to hand over the request to a free child process to execute. This mechanism is called fastcgi, and this process no longer requires a Web server to be started and destroyed. It works on the socket. So that the Web server and the dynamic server process can be placed on different hosts

The user requests a static content Web server to return directly. If it is a dynamic page, the Web is sent to a dynamic server process on another host through TCP/IP.

#################################################################

Dynamic server processes and databases are CPU-intensive

program = instruction + data

Data: Database server

With little data, you can create a file locally. If a lot is dedicated to a database server.

Database tier | Application Layer |web Server layer

|          | |

MySQL PHP Apache

\        | /

LAMP

On the same server can also be

|

Hadoop Thousands of machines work together for maximum efficiency

|

How to make computational power more efficient, be sure to squeeze dry and squeeze your CPU

################################################

Installing httpd

1, yum-y install httpd

2, RPM-QL httpd look at the installation of which

/ETC/HTTPD/CONF/HTTPD.CONF Master configuration file

/etc/httpd/conf/magic defines how to parse non-plain text documents

/ETC/RC.D/INIT.D/HTTPD Service Script

/ETC/RC.D/INIT.D/HTTPD configuration file for the service script

/usr/bin/ab Server pressure Performance test

/var/www Web File storage path

3. Service httpd Start

4, NSTSTAT-TNLP | Grep:80

5, Ps-aux | grep httpd found that there are already many idle processes

6, search the Web page of their own virtual machine IP will see Redhat settings Welcome page

7, welcome page configuration file in/etc/httpd/conf.d/welcome.conf

8, the default page path under the/var/www/html path

9. Create the a.html in the 8 directory

10.

<title>hello world</title>

Welcome to our website

11. No Restart Required

12, we go to see httpd configuration file, first copy, to prevent the wrong change

13, cp/etc/httpd/conf/httpd.conf Httpd.conf.bak

14. This configuration file is divided into three segments:

Section 1: Global Environment

Section 2: Primary server Configuration

Section 3: Virtual host

Second and third cannot take effect at the same time. Default 2

After the siren is the comment information, the siren is not followed by the space is the option can be enabled

Directives are case-insensitive, parameters and paths are strictly case-sensitive

15. The Servicetokens OS in this file is used for management: when searching for pages that do not exist, return information about the host, etc.

16. We want to change the OS to Servicetokens Major

17, install httpd-manual This package will automatically generate a configuration file

/etc/httpd/conf.d/menu.conf

Restart Service

18, search 192.168.9.247/manual/can see help information

19, continue to look at the configuration file:serviceroot Server root directory

20, Pidfile run/httpd.pid PID number of the storage path

21. Timeout time-out root TCP-related

22, KeepAlive whether to use long links if the traffic is not particularly large, it opens. No three handshakes per link

23, Maxkeepaliverequests Long link does not time out, but limit you to request 100 more than 100 to re-queue.

24, KeepAliveTimeout 15 do not make other requests 15 seconds of automatic disconnection, for the busy server can be reduced a bit

25, LoadRunner This tool can really test the server running condition

26, continue: MPM multi-channel processing module; Defines the model that Apache works with when the appropriate number of user requests

Common:

Mpm_vinnt (Window Pro)

Worker (a process that uses multiple threads to respond to user requests) 2.2 Resource consumption is much, and there will be a lot of process switching; c5>

Event (a process that processes multiple user requests directly) is supported after version 2.4, which is the most powerful

Prefork (pre-established process on Linux): Let the process directly handle user requests

Interview Question: The difference between a Web server centralized model

27. HTTPD-L lists the models supported by the current server

28. Show no worker model but RPM-QL httpd | grep bin can see/usr/sbin/httpd.worker has

29, if we want to use the worker this model to vim/etc/sysconfig/httpd the path change

30, 2.4 version re-use the event model

31. Continue the configuration file:

<module prefork.c>

Startservers 8 How many idle processes will start when the server starts

Minspareservers 5 Minimum Idle 5 processes

Maxspareservers 20 Max Idle Process

Serverlimit 256 Specify an upper value for maxclients (if the server is switched off)

MaxClients 256 maximum clients, maximum number of users allowed to connect at the same time

Maxrequestsperchild 4000 The maximum number of times each child process responds to a user request

</IfModule>

########################################

<ifmodule worker.c>

Startservers 2 The default number of processes to start

MaxClients 150 maximum number of user requests to be allowed to connect in

Minsparethreads 25 min Idle thread

MAXSPARETHREADS 75 Max Idle thread

Threadsperchild the maximum number of threads generated by 251 processes

Maxrequestsperchild 0 Maximum number of requests per process response

Which value is best for your model needs testing

Listen 80 Monitoring

32, LoadModule: Which module does not need to comment out

33, Include conf.d/*.conf CONF.D All the files are part of the main configuration file

Then go down to the main service segment, and the virtual host segment

Apache httpd installation and configuration files and their descriptions

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.