CGI: A protocol that invokes the execution environment to execute a binary program and convert the format to HTML recognition
FastCGI: Is the Apache server acting as a client, PHP is no longer an interpreter, but a server, also similar to the Apache Prefork working model, called FastCGI
Programming languages
1. Static language: Compiled language
C, C + + JAVA
2. Dynamic language: interpreted language
Shell, Perl, Python
First, PHP's opcode
OpCode is a PHP script-compiled intermediate language, like Java's bytecode, or. Net of MSL. PHP executes PHP script code generally through the following 4 steps (to be exact, it should be PHP language engine Zend)
1, scanning (lexing)--Convert the PHP code to a language fragment (Tokens), can also be solved as lexical analysis
2. parsing--converts tokens into simple and meaningful expressions, which can also be interpreted as grammatical analysis.
3, compilation--to compile the expression into opcodes, can also be solved to compile
4, execution--sequential execution of opcodes, one at a time, thus realizing the function of PHP script
Note: PHP only needs to be compiled at the first run, it will not need compiling, so the first visit is slow. The opcode is not stored on a disk, but is placed in memory.
Second, the accelerator of PHP
The opcode file compiled by each process is placed in a cache, which can be accessed by all processes to improve access speed
Accelerators are available in the following versions and are open source:
1. APC (alternative PHP Cache)
2, Eaccelerator
3, XCache
4, Zend Optimizer and Zend Guard Loader (closed source but free)
5, Nusphere phpexpress
Catalog comparison flows to a third accelerator and is heavily used in production environments
Third, PHP source directory structure
1, build: Mainly put some files related to the source code compilation, such as the buildconf script before starting to build and an environment script
2, Ext: The official extension directory, including most of the PHP function definition and implementation
3, main:php the most core files, is the implementation of PHP infrastructure, and Zend engine is not the same, Zend mainly to achieve the language of the core language operating environment
4, Zend:zend engine, such as script notation syntax explanation, opcode implementation and extension mechanism implementation, etc.
5. pear:php extension and application warehouse, including pear core files
6, SAPI: Contains the various server abstraction layer code, such as Apache mod_php, cgi,fastcgi and FPM interface
7, tsrm:php thread safety, is built on the TSRM library
8. tests:php Test Script Collection
9, Win32: This directory mainly includes some implementations related to Windows platform, such as the implementation of SOKCET
MVC: Embedded Web Development language. module, view, controller, will use view call execution result, return to Apache server
In the later version of PHP5, FastCGI is made into a module with the module name: FPM
The apache+php is generally constructed as:
Cgi
Module
FastCGI (need to configure PHP server, compile PHP's fpm function)
Only deal with static content, Nginx performance is much better than Apache
nginx+fpm
PHP Installation
Php-mbstring.x86_64:(most byte) PHP multi-byte support, internationalized when used, all general to install
[[email protected] httpd]# Yum install php php-mbstring[[email protected] httpd]# rpm-ql php/etc/httpd/conf.d/php.conf/u Sr/lib64/httpd/modules/libphp5.so/var/lib/php/session/var/www/icons/php.gif
php.conf configuration file:
## php is an html-embedded scripting language which attempts to make it# easy for developers to write dynamically generated webpages.#<IfModule prefork.c> #定义apache不同的工作模型, referring to different PHP modules loadmodule php5_module modules/libphp5.so</ifmodule><ifmodule worker.c> loadmodule php5_module modules/libphp5-zts.so</ifmodule>## cause the php Interpreter to handle files with a .php extension. #AddHandler php5-script .php #定义的一个处理器, Access. PHP to run with Php5-script addtype text/html .php #定义类型, Access. php files, he treats him as a txt/html document ## add index.php to the list of files that will be served as directory# indexes.# directoryindex index.php #定义php默认主Page,index.php## uncomment the following line to allow php to pretty-print .phps# files as php source code:# #AddType application/ X-httpd-php-source .phps
index.php Syntax:
[Email protected] a.com]# vim index.php #网站默认php网页文件 <title>A</title>
index.php files typically contain only directives, do not contain data, and data are interactive with another mechanism
Data is implemented with database access to quickly find and respond
This article is from the "Wei Zhenping" blog, please be sure to keep this source http://leozhenping.blog.51cto.com/10043183/1662418
PHP vs Apache