A: Brief description
Hypertext Transfer Protocol (Http,hypertext Transfer Protocol) is one of the most widely used network protocols on the Internet. All WWW documents must comply with this standard.
HTTP is a standard (TCP) for client and server-side requests and responses. The client is the end user and the server side is the Web site. By using a Web browser, crawler, or other tool, the client initiates an HTTP request to the specified port on the server (the default port is 80). (We call this client) called the user agent. The answering server stores (some) resources, such as HTML files and images. This answering server (we call it) is the source server (Origin server). There may be multiple middle tiers, such as proxies, gateways, or tunnels (tunnels), between the user agent and the source server. Although the TCP/IP protocol is the most popular application on the Internet, the HTTP protocol does not stipulate that it must be used and (based on) the layers it supports. In fact, HTTP can be implemented on any other Internet protocol, or on other networks. HTTP only assumes that (its underlying protocol provides) a reliable transmission, and any protocol that provides such assurances can be used by it.
Typically, a request is initiated by an HTTP client to establish a TCP connection to the server-specified port (by default, port 80). The HTTP server listens on that port for requests sent by the client. Once the request is received, the server (to the client) sends back a status line, such as "http/1.1 OK", and (in response) message, the message body may be the requested file, error message, or some other information.
The reason HTTP uses TCP instead of UDP is that a Web page must transmit a lot of data, while the TCP protocol provides transport control, organizes the data sequentially, and corrects errors.
The resources requested through the HTTP or HTTPS protocol are identified by the Uniform Resource Identifier (Uniform Resource Identifiers) (or, more accurately, URLs).
The HTTP protocol (hypertext Transfer Protocol, Hypertext Transfer Protocol) is a transport protocol used to transmit a hyper-text to a local browser from a WWW server. It can make the browser more efficient and reduce the network transmission. It not only ensures that the computer transmits hypertext documents correctly and quickly, but also determines which part of the document is being transmitted, and which content is displayed first (such as text before graphics), and so on.
HTTP is the application-layer communication protocol between a client browser or another program and a Web server. The hypertext information is stored on the Web server on the Internet, and the client needs to transmit the hypertext information it wants to access over the HTTP protocol. HTTP contains commands and transmission information that can be used not only for Web access, but also for communication between other Internet/intranet application systems, enabling the integration of hypermedia access for a variety of application resources.
The website address that we enter in the address bar of the browser is called the URL (Uniform Resource Locator, Uniform Resource Locator). Just like every household has a house address, each page has an Internet address. When you enter a URL in the Address box of the browser or click a hyperlink, the URL determines the address to be browsed. The browser uses Hypertext Transfer Protocol (HTTP) to extract Web page code from Web servers and translate them into beautiful web pages.
Second: Experimental brief
Lamp is the most basic combination of Web services, and this series describes the various ways to deploy the lamp combination, including:
RPM Package-based implementations:
httpd and PHP are in the same way as module, which is PHP as a httpd modular way to provide services
HTTPd and PHP are combined in the same way as fastcgi, which is PHP as a standalone process, with httpd between the use of FASTCGI protocol to provide services
Based on the compilation installation implementation:
httpd and PHP are in the same way as module, which is PHP as a httpd modular way to provide services
HTTPd and PHP are combined in the same way as fastcgi, which is PHP as a standalone process, with httpd between the use of FASTCGI protocol to provide services
This article shows the use of the RPM package, PHP and httpd in the way of the module mode
Contains the lamp installation
HTTPD Configuration of virtual hosts (IP-based, Port-based, host-based name)
HTTPD based on Basic authentication
HTTPD IP-based access control
Configuration of the status page for httpd
Configuration of path aliases for httpd
Environment description
Using the CENTOS7 system
Install related packages with Yum
Build a Yum source repository and configure DNS
In order to avoid other problems during the test, first clear the firewall (iptables), SELinux set to Disabled
The first part: RPM package installation lamp related software, for simple configuration
1. Install HTTP, PHP, Mariadb-server, Php-mysql
httpd as a Web server
Mariadb-server as a database server
PHP when HTTPD is combined with module, the package used (if combined with fastcgi, you need to install PHP-FPM)
Php-mysql PHP Connection when MySQL database extension module
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/89/C8/wKioL1gcVxjxB3HOAADsXEVsjYQ220.png "title=" QQ picture 20161104173847.png "Width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:900px;height:240px " alt= "Wkiol1gcvxjxb3hoaadsxevsjyq220.png"/>
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/89/CB/wKiom1gcV-OA4azwAACbtFxrG1U755.png "title=" QQ picture 20161104174215.png "Width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:900px;height:300px " alt= "Wkiom1gcv-oa4azwaacbtfxrg1u755.png"/>
2. Modify the httpd configuration file and the MARIADB configuration file
Modify the httpd configuration file to enable it to start normally
[[Email protected] 7 ~] #vim/etc/httpd/conf/httpd.conf
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/89/C9/wKioL1gcb_GBKBGAAAA7xRtQCic835.png "title=" Qq20161104192230.png "alt=" Wkiol1gcb_gbkbgaaaa7xrtqcic835.png "/>
Modify the MARIADB configuration file to enable it to start normally
[[Email protected] 7 ~] #vim/etc/my.cnf
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/89/C9/wKioL1gccXfhoUh1AABQV8UCXf0857.png "title=" Qq20161104193047.png "alt=" Wkiol1gccxfhouh1aabqv8ucxf0857.png "/>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/89/CC/wKiom1gcdEGCOF1WAABMWhhJPKM337.png "title=" Qq20161104194147.png "alt=" Wkiom1gcdegcof1waabmwhhjpkm337.png "/>
3, simple configuration of MySQL, enhance its security, create and authorize account, for PHP connection use
When starting the database for the first time, it is recommended to use the Mysql_secure_installnation (Security Configuration Wizard) for security-related initialization settings to enhance MySQL security
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476449732312700.png "alt=" 1.png "/>
Create a user account that allows PHP to connect to the database using
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/89/CF/wKiom1gdRlTBHLqlAAB0JOUFMXk700.png "title=" Qq20161105102051.png "alt=" Wkiom1gdrltbhlqlaab0joufmxk700.png "/>
Provide a test page for testing
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/89/CC/wKioL1gdRrOSyLP8AABN5gPsvF4601.png "title=" Qq20161105103106.png "alt=" Wkiol1gdrrosylp8aabn5gpsvf4601.png "/>
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/89/CC/wKioL1gdRtqhX8vcAAA5otsrOL8347.png "style=" float: none; "title=" Qq20161105102937.png "alt=" Wkiol1gdrtqhx8vcaaa5otsrol8347.png "/>
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/89/CF/wKiom1gdRtvQ8j3XAABmTRWndVM421.png "style=" float: none; "title=" Qq20161105103021.png "alt=" Wkiom1gdrtvq8j3xaabmtrwndvm421.png "/>
Second, httpd related configuration display
1. Configure the IP-based virtual machine host
Add IP to this machine first
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/89/CF/wKiom1gdUeSAQbLYAACgQL6mFGg280.png "title=" Qq20161105111842.png "alt=" Wkiom1gduesaqblyaacgql6mfgg280.png "/>
Editing a configuration file
Vim/etc/httpd/conf/httpd.conf (documentroot: Website root directory)
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/89/CC/wKioL1gdUgyzMmrBAAAvj_SSWyQ882.png "title=" Qq20161105112317.png "alt=" Wkiol1gdugyzmmrbaaavj_sswyq882.png "/>
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/89/D0/wKiom1gdc57QmhSzAACDjUGsoZQ653.png "title=" Qq20161105135142.png "alt=" Wkiom1gdc57qmhszaacdjugsozq653.png "/>
Provide different test pages for different virtual hosts
MKDIR/TESTDIR/{WWW1,WWW2}
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/CD/wKioL1gddGTRV9o7AAAmOs_rwZA266.png "style=" float: none; "title=" Qq20161105135543.png "alt=" Wkiol1gddgtrv9o7aaamos_rwza266.png "/>
Check the configuration file for incorrect syntax, restart the service without error, and then test
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/89/D0/wKiom1gddGWgbp7WAAAYghIoVCM178.png "style=" float: none; "title=" Qq20161105135457.png "alt=" Wkiom1gddgwgbp7waaayghiovcm178.png "/>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/89/CD/wKioL1gddTuyPGAbAAAvKro0TBY159.png "title=" Qq20161105131141.png "alt=" Wkiol1gddtuypgabaaavkro0tby159.png "/>
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/89/CD/wKioL1gddQvgptrIAAAwbw4GNvw411.png "style=" float: none; "title=" Qq20161105131124.png "alt=" Wkiol1gddqvgptriaaawbw4gnvw411.png "/>
Configure a port-based virtual host
Modifying a configuration file
Vim/etc/httpd/conf/httpd.conf
Add an item:
Listen 80
Listen 8080
Vim/etc/httpd/conf.d/vhost.conf
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/89/CD/wKioL1gdhDDBVuV_AACT0_nvFag052.png "style=" float: none; "title=" Qq20161105150233.png "alt=" Wkiol1gdhddbvuv_aact0_nvfag052.png "/>
Restart the service when the port and Web root path are modified in the master configuration file
Httpd-t
Systemctl Restart Httpd.service
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/89/D0/wKiom1gdhDHA9FDnAAAoQsFlykY397.png "style=" float: none; "title=" Qq20161105145911.png "alt=" Wkiom1gdhdha9fdnaaaoqsflyky397.png "/>
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/89/CD/wKioL1gdhRyzDCYFAAAuR_C3aG4447.png "style=" float: none; "title=" Qq20161105145811.png "alt=" Wkiol1gdhryzdcyfaaaur_c3ag4447.png "/>
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/89/CD/wKioL1gdhRzDPO_zAAA5-xCtuvQ237.png "style=" float: none; "title=" Qq20161105145755.png "alt=" Wkiol1gdhrzdpo_zaaa5-xctuvq237.png "/>
Configure a host-name-based virtual host
Modifying the httpd configuration file
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/89/CD/wKioL1gdidSgy4w2AACUl0v3taI831.png "title=" Qq20161105152521.png "alt=" Wkiol1gdidsgy4w2aacul0v3tai831.png "/>
Check configuration file syntax error, restart HTTPD service
Modify the host file of the test master so that it resolves to the 10.1.50.66 host for both www.a.com and www.b.com, and then test
Windowsdns file path: C-Drive/windows/system32/driver/etc/hosts
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/89/CD/wKioL1gdisThAnQAAAB0sXQZsOM299.png "style=" float: none; "title=" Qq20161105152310.png "alt=" Wkiol1gdisthanqaaab0sxqzsom299.png "/>
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/89/D0/wKiom1gdis2QOse9AAAuPVGZOzU916.png "style=" float: none; "title=" Qq20161105152341.png "alt=" Wkiom1gdis2qose9aaaupvgzozu916.png "/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/89/CD/wKioL1gditWzAlAmAAAvpNw-nx8768.png "style=" float: none; "title=" Qq20161105152550.png "alt=" Wkiol1gditwzalamaaavpnw-nx8768.png "/>
4. Configure user authentication based on Basic authentication
Modifying the httpd configuration file
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476454489246159.png "alt=" Blob.png "/>
Create an authentication file
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476453518145394.png "alt=" Blob.png "/>
Provide the corresponding test page, reload the configuration file, and test
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476454040843088.png "alt=" Blob.png "/>
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476454533392330.png "alt=" Blob.png "/>650) this.width=650;" Src= "http://www.178linux.com/ueditor/php/upload/image/20161014/ 1476454597127407.png "alt=" Blob.png "/>
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476454664642914.png "alt=" Blob.png "/>
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476454688231594.png "alt=" Blob.png "/>
5, configure the IP-based access control mechanism
Modify the httpd configuration file
Vim/etc/httpd/conf.d/vhost.conf
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476455863495289.png "alt=" Blob.png "/>
Check the configuration file syntax, and then reload the configuration file for testing
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476455599533566.png "alt=" Blob.png "/>650) this.width=650;" Src= "http://www.178linux.com/ueditor/php/upload/image/20161014/ 1476455533339551.png "alt=" Blob.png "/>
6, based on the HTTPD status page configuration
Modifying the HEEPD configuration file
Vim/etc/httpd/conf.d/vhost.conf
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476456441785205.png "alt=" Blob.png "/>
After modifying the configuration parameters, check syntax for syntax errors, overloading the configuration file
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476456271417455.png "alt=" Blob.png "/>
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476456322377833.png "alt=" Blob.png "/>
7, configuring Path aliases
Modifying the httpd configuration file
Vim/etc/httpd/conf.d/vhost.conf
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476457026982654.png "alt=" Blob.png "/>
Provide the test page under/AAA/BBB, check the httpd configuration syntax, reload the file
650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20161014/1476456795182096.png "alt=" Blob.png "/>650) this.width=650;" Src= "http://www.178linux.com/ueditor/php/upload/image/20161014/ 1476457083670196.png "alt=" Blob.png "/>
Lamp based on RPM package construction