Linux Web Services and HTTP protocol basic concepts

Source: Internet
Author: User

Today we say that the Apache in the Web server, in the early days is basically the Web server market share of the highest open source Web server products, its features, stability and open source, making Apache very popular. Let's take a look at the web-related knowledge and some applications of httpd


First, web-related knowledge

1. Uri and URL

Uri:uniform Resource indentifier, Uniform Resource Identifier. Globally, the naming of a single resource that can be uniquely referenced is called a Uniform resource identifier; Unification refers to the unification of the path format.

Url:uniform Resource Locator, a Uniform Resource locator, used to describe the uniform representation format of Internet resources on the Internet, is a subset of URIs. Represents a format of protocol://host:port/path/to/file


2. Web Resources (objects)

A resource that can be uniquely tagged by a URL and that can be accessed by a client is called a Web resource, or a Web object, such as http://www.baidu.com/logo.gif; multiple resources are likely to be consolidated into an HTML document


3. HTTP Method

    • HEAD

    • GET

    • PUT

    • POST

    • DELETE

    • TRACE

    • OPTIONS

    • CONNECTION


4. MIME

Multipurpose Internet Mail Extension, multi-purpose Internet Mail extension, to re-encode non-text data before transmission to text format, the receiver can revert to the original format in the opposite way, but also can call the appropriate program to open the file


5. MVC

The full name of MVC is the model View Controller, which is the abbreviation for the models-view-controller, a software design paradigm that organizes the code with a method of business logic, data, and interface display separation. Aggregating business logic into a single component does not require rewriting business logic while improving and personalizing the interface and user interaction.


6. Request message and corresponding message

(1), Request message Syntax

<method> <request-URL> <version>

(2), Response message Syntax

<version> <status> <reason-phrase>

7. HTTP Status Code

①1xx: Pure information Class

②2xx: Information on "Success" Class (201, 202)

③3xx: Redirect class information (301, 302, 304)

④4xx: Information for the client error class (404)

⑤5xx: Server-side error class information


8, the main operation of the Web server

① Establishing a connection--accepting or rejecting a client connection request

② receiving requests-Read HTTP request messages over the network

③ Processing Request--parsing the request message and making the corresponding action

④ Access Resources-resources related to access request messages

⑤ Build Response-generates an HTTP response message with the correct header

⑥ Send response-sends a generated response message to the client

⑦ Logging--When a completed HTTP transaction is logged into the log file

9, http/1.1

Enhanced caching capabilities

Long connection: keep-alive


10, Mpm:multi-processing Modules

①mpm_winnt:windowsnt Dedicated


②prefork ( One request responds with one process, starting multiple processes)

<IfModule prefork.c>StartServers       8                  #  The number of httpd processes started at the start of the service minspareservers    5         The minimum number of idle processes maintained during the operation of the           #  service maxspareservers    20                 The maximum number of idle processes maintained during the operation of the    #  service serverlimit      256                  #  Specify maxclients Upper Limit maxclients       256                  #  The maximum number of concurrent requests that a service is allowed to request connections during the run maxrequestsperchild  4000       &nbspThe maximum number of user requests per process allowed to be processed by the;      #  service during the run </IfModule> 

③worker (one request responds with one thread, (starting multiple processes, generating multiple threads per process))

<ifmodule Worker.c>startservers 4 # Number of httpd processes started at service startup MaxClients 300 # The maximum number of users allowed to request connections during service run       Minsparethreads 25 # The minimum number of idle threads maintained during the service run Maxsparethreads 75 # The maximum number of idle threads maintained during the service run Threadsperchild 25 # The number of threads generated per process Maxrequestsperchild 0 # The maximum number of user requests per process allowed (0, because threads are processing user requests, not processes) </IfModule>

④event (one process handles multiple requests)


11, httpd

-V: View httpd service version and compiled parameters

-L: Displays a list of modules compiled into httpd, but does not show dynamic modules loaded with Loadmodules

-M: Displays the loaded static and dynamic modules

-T: Check configuration file for syntax errors



12. User-or group-based access control

(1), allowing users to access

allowoverride authconfigauthtype basicauthname "Personal area ..." AuthUserFile "/etc/httpd/conf/.htpasswd" Require Valid-usertouch/etc/httpd/conf/.htpasswdhtpasswd-c-m/etc/httpd/conf/.htpasswd tomhtpasswd-m/etc/httpd/conf/. HTPASSWD Hadoop

(2), allow user groups to access

allowoverride authconfigauthtype basicauthname "Personal area ..." AuthUserFile "/etc/httpd/conf/.htpasswd" AuthGroupFile "/etc/httpd/conf/.htgroup" Require Group groupnametouch/etc/httpd/conf/.htpasswdtouch/etc/httpd/conf /.htgrouphtpasswd-c-m/etc/httpd/conf/.htpasswd tomhtpasswd-m/etc/httpd/conf/.htpasswd hadoop/etc/httpd/conf/. Htgroup format: Groupname:user1 user2 ...

13. IP-based access control

AllowOverride Noneorder Deny,allowdeny from 172.16.1.100 address representation method ip:172.16.1.110network/netmask:172.16.1.110/ 16host:www.soysauce.com domain name:soysauce.comPartial ip:172.16 (172.16.0.0/16)

14. User's personal home directory site

Note Userdir disabled enable Userdir Public_htmluseradd hadoopsu-hadoopmkdir Public_htmlecho "Hadoop's personal site" >> Public_html/index.htmlchmod O+x/home/hadoopexitservice httpd Restart

15, PV and UV

PV (page View): Number of pages visited per day

UV (User View): Independent IP traffic per day


16. Path aliases

Alias/url "Local_path" for example: alias/images/"/tmp/test" http://172.16.1.102/images/is equivalent to accessing the document under the Tmp/test directory

17. Virtual Host Configuration

(1), IP-based virtual host configuration

<VirtualHost 172.16.1.110:80>    ServerName www.a.com     DocumentRoot  "/data/www/a.com"     CustomLog  "/var/log/httpd/a.com/access_ Log "    ErrorLog "/var/log/httpd/a.com/error_log "    < directory  "/data/www/a.com" >        Options none         AllowOverride none         Order Deny,Allow        Allow From all     </Directory></VirtualHost><VirtualHost 172.16.1.111:80>     ServerName www.b.net    DocumentRoot  "/data/www/b.net"      CustomLog  "/var/log/httpd/b.net/access_log"     ErrorLog  "/var/log/ Httpd/b.net/error_log "    <directory  "/data/www/b.net" >        Options  none        allowoverride none         Order Deny,Allow        Allow From  All    </directory></virtualhost>

(2), Port-based virtual host configuration

<VirtualHost 172.16.1.110:80>    ServerName www.a.com     DocumentRoot  "/data/www/a.com"     CustomLog  "/var/log/httpd/a.com/access_ Log "    ErrorLog "/var/log/httpd/a.com/error_log "    < directory  "/data/www/a.com" >        Options none         AllowOverride none         Order Deny,Allow        Allow From all     </Directory></VirtualHost><VirtualHost 172.16.1.110:8080>     ServerName www.c.edu    DocumentRoot  "/data/www/c.edu"      CustomLog  "/var/log/httpd/c.edu/access_log"     ErrorLog  "/var/log/ Httpd/c.edu/error_log "    <directory  "/data/www/c.edu" >        Options  none        allowoverride none         Order Deny,Allow        Allow From  All    </directory></virtualhost>

(3), hostname-based virtual host configuration

DNS resolution correctly resolves two host names to their IP addresses/etc/hosts172.16.1.103    www.b.net172.16.1.103     www.d.org NameVirtualHost 172.16.1.111:80<VirtualHost 172.16.1.111:80>     ServerName www.b.net    DocumentRoot  "/data/www/b.net"      CustomLog  "/var/log/httpd/b.net/access_log"     ErrorLog  "/var/log/ Httpd/b.net/error_log "    <Directory "/data/www/b.net ">         Options none        AllowOverride  none        order deny,allow         Allow From all    </Directory></VirtualHost>< virtualhost 172.16.1.111:80>    servername www.d.org     documentroot  "/data/wwW/d.org "    CustomLog "/var/log/httpd/d.org/access_log "     errorlog  "/var/log/httpd/d.org/error_log"     <Directory  "/data/www/d.org" >         Options none         AllowOverride none        Order Deny,Allow         allow from all    </directory></ Virtualhost>

18. Default Virtual Host Configuration

<virtualhost _default_:80>documentroot/www/default80# ... </virtualhost><virtualhost _default_:* >documentroot/www/default# ...</virtualhost>

19. Server-status Configuration

<Loacation/server-status> SetHandler server-status Order Deny,allow deny from all to 172.16.1.1 02</location><location> directives for defining url<directory> directives for local file system paths

20. CGI Scripts

Modify Master Profile httpd.conf enable LoadModule cgi_module modules/mod_cgi.so scriptalias/cgi-bin/"/var/www/cgi-bin/" in/var/www/ Create a script under the Cgi-bin directory Test#!/bin/bashcat << eofcontent-type:text/html<pre>

21. How Apache and PHP are combined

①cgi

②module

③fastcgi




This article is from the "Hello,linux" blog, make sure to keep this source http://soysauce93.blog.51cto.com/7589461/1725316

Linux Web Services and HTTP protocol basic concepts

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.