Apache features easy to understand

Source: Internet
Author: User
Tags phpmyadmin

implementation of the HTTP protocol has a lot of programs, more famous is:IIS is currently the most used on the market,Nginx Use of the number is fast Plus,Apache Ancient. Apache Though is being ... But we also have to learn that its market share is still some, and its implementation is more classic.

The above is only the implementation of static data transmission on the HTTP protocol, as well as the dynamic part of the information, Dynamic Data is the data can be changed, the change is based on the browser's different pages to display different data. The implementation language of the Dynamic Web page is:PHP Implementation of its service is also called PHP;ASP. NET implements IIS,IIS is not only a static server but also a dynamic server; JavaScript implements it a lot of the most famous is Tomcat, it can also provide static pages.

ahttpthe static data implementationApache1Work Flow

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/8B/B7/wKiom1hWhwSRWdkZAACbYxTsf-A824.png "title=" are. png "alt=" Wkiom1hwhwsrwdkzaacbyxtsf-a824.png "/>

is a the process by which Apache processes a request

2configuration file Distribution

Apache2.4 configuration file is scattered in multiple files, the main configuration file in the/etc/httpd/conf directory, the module configuration file in the/ETC/HTTPD/CONF.MODULES.D directory, The other configuration files are in the /etc/httpd/conf.d directory.

3Master configuration file

some important basic configurations in the master configuration file, Apache feature Settings I'll say it separately.

ServerRoot "/ETC/HTTPD" #日志的存放目录Listen #监听的端口User Apache #用户Group Apache #组ErrorLog "Logs/error_log" #错误日志日志LogLevel W Arn #错误日志级别, other levels debug, info, notice, warn, error, Crit,alert, Emerg.<ifmodule log_config_module></ifmodule > between these two definitions is the Access log format and level below four lines are error from qualitative definition, definition is defined according to response status code, of course we can also define more #errordocument "The server made Aboo Boo" according to the status code. #ErrorDocument 404/missing.html#errordocument 404 "/cgi-bin/missing_handler.pl" #ErrorDocument 402http:// Www.example.com/subscription_info.html

Enablesendfile on # This is especially important when you enable this feature, the process of processing static data becomes, and can be compared to the previous picture, which reduces the number of copies of data. This occurs mainly because the static data does not need to be processed, and the content after the disk is read is what we want to return to the user.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/8B/B7/wKiom1hWh0HTPZN2AACLJplVbdw057.png "title=". png " alt= "Wkiom1hwh0htpzn2aacljplvbdw057.png"/>

4provides path and path attribute definitions for content
DocumentRoot "/var/www/html" #默认提供网页页面的路径 <directory "/var/www/html" >options indexesfollowsymlinks # Indexes displays the files in the directory, FollowSymLinks displays the contents of the original file of the linked file, SymLinksIfOwnerMatch displays the contents of the file when the link file and the original file are the same owner, EXECCGI allows the script to run #    AllowOverride controls what directives is placed in files. #It can be ' "", "none", or any combination of the Keywords:allowoverride None #不允许路径重写, all allow overrides, the overriding method can be written in this current file can also be written in the target rewrite. Require all granted #允许任何人访问 in the. htaccess file, you can also define which users are logged on with, and basically no one is using it. </Directory>
5Persistent Connections
KeepAlive on KeepAliveTimeout 30ms maxkeepaliverequests 20
6 mode
<ifmodule prefork.c>startservers 8 #服务启动时启动的子进程数MinSpareServers 5 #最少空闲子进程数MaxSpareServers 20ServerLi MIT #同时启动的子进程数上限MaxClients #同时服务的客户端数上限 (Maximum supported concurrency) Maxrequestsperchild 4000 #每个子进程在其生命周期内处理的请求数上限 &L T;/ifmodule> <ifmodule worker.c>startservers 4 #服务启动时启动的子进程数MaxClients 300MinSpareThreads 25 Maxsparethreads 75ThreadsPerChild #每个子进程可启动的线程数MaxRequestsPerChild 0 #每个子进程可处理的请求数, 0 means unlimited </ifmodule> ;
7Compression

This content is defined in the <directory.

Setoutputfilter DEFLATE addoutputfilterbytype DEFLATE text/html text/plain text/css text/xmltext/javascript # There are other compression options Browsermatch "^MOZILLA/2" No-gzip #不支持压缩的直接返回原文件


8 HTTPSImplement

the first is to obtain the certificate this can refer to http://oldking.blog.51cto.com/10402759/1882421

then put these three files in the following directory, as well as the installation package Mod_ssl

[Email protected] ~]# ls/etc/httpd/ssl/httpd.crt HTTPD.CSR httpd.key[[email protected] ~]# vim/etc/httpd/conf.d/ ssl.conf# edit the following two lines sslcertificatefile/etc/httpd/ssl/httpd.crtsslcertificatekeyfile/etc/httpd/ssl/httpd.key# add the following five elements <directory "/www/phpmyadmin-4.4.14.1-all-languages" > Options none allowoverride none Require all Granted</di Rectory>
9 httpprotocol Redirection toHttps
<directory "/www/phpmyadmin-4.4.14.1-all-languages" > Options Indexes followsymlinks allowoverride all #允许重写, This is the key to rewriting the path Require all granted</directory> edit the/www/phpmyadmin-4.4.14.1-all-languages/.htaccess file Rewriteengine Onrewritecond%{server_port}!^443$rewriterule ^.* $https://%{server_name}%{request_uri} [L,R]
twohttpimplementation of Dynamic DataPHP1 Apacheand thePhpmeans of communication

There are three kinds,1Apache call PHP in a modular way , 2Apache and php through fastcgi mode communication;3 through This implementation of CGI mode communication is basically no one to use.

at present , FASTCGI is replacing the module mode, the reason is that because the response request through the module, each time the PHP request to start a PHP process, complete the request and destroy the process, This process will waste a lot of time. fastcgi mode is to put PHP directly in memory, when used to send a request directly to 127.0.0.1:9000 can be, reduce the process of generating the destruction of consumption.

PHP configuration file must be closed display_errors

Post_maxsize

2 XCache

XCache is a tool for speeding up PHP requests, especially for dynamic web pages that have a particularly high frequency of access. It is the function of the PHP request for the message and processed data to save, the next time you encounter the same request can be directly responded to. The academic point is that XCache can create a cache space in memory, put any process compiled opcode in the cache space, the next time a process needs to access the same file can go directly to cache space to take the steps to eliminate the compilation.

threeFour site templates

WordPress This is the open source php personal blog Template

Phpwind Forum Templates

Discus Forum Templates

phpMyAdmin database MySQL Web management tool

these four Web site template implementations can help us get familiar with php .

Summary

This section basically says it's all about the configuration file . Apache commonly used features, sub so do not write specific steps are mainly online similar blog particularly much. This section focuses onthe persistent connection of Apache, which needs to be groped according to the specific selection of production environment;Apache compressed transmission;HTTPS transmission, many websites are slowly implementing the whole station HTTPS ; redirect; try to use fastcgi mode communicationbetween Apache and php; XCache speed up PHP requests. There are also four page templates that are best implemented once.


This article is from "Lao Wang Linux Journey" blog, please be sure to keep this source http://oldking.blog.51cto.com/10402759/1883805

Apache features easy to understand

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.