Home > Article > Backend Development > How to run php source code in win
There are three main ways to run PHP so far:
a. Run by module loading , it may not be easy for beginners to understand, but it is actually integrating PHP into the Apache server and running it in the same process. (Recommended learning: PHP video tutorial)
b. Run in CGI mode. CGI is called the public gateway interface in English, which is when Apache encounters a PHP script The PHP program will be submitted to the CGI application (php-cgi.exe) for interpretation, and the results after the interpretation will be returned to Apache, and then the user will respond to the request.
c, run in FastCGI mode. This form is an enhanced version of CGI. CGI is a single-process, multi-threaded running method. The program will be destroyed after it is executed, so you need to load the configuration and environment variables each time fork-and-execute (create-execute) ).
FastCGI is different. FastCGI is like a long-live CGI. It can be executed all the time. As long as it is activated, it will not take time to fork every time.
FastCGI process manager initializes itself, starts multiple CGI interpreter processes (multiple php-cgi.exe visible in the task manager) and waits for connections from the Web Server.
No matter which of the above methods is used, the following configuration will usually be added. Unzip the PHP installation package to c:/PHP5/, rename the PHP.ini-recommend file to PHP.ini, and find the following fields to edit. Remove the semicolon in front of it (be careful not to remove the wrong semicolon, many of them are comment information, so identify them carefully).
error_reporting = E_ALL //开启报错,便于程序员查错 line 342 display_errors = On //显示错误 line 373 extension_dir = "C:/php5/ext" //php的扩展选项文件所在的目录 line 542 date.timezone = Asia/shanhai //时区配置 line 716
Run as a module, add the following configuration to the configuration file of Apache (C:/Program Files/Apache Software Foundation/Apache2.2/conf)
LoadModule php5_module "C:/php5/php5apache2_2.dll" //大约line 127 PHPinidir "C:/php5/php.ini" //修改配置 DirectoryIndex index.html index.php//追加index.php AddType application/x-httpd-php .php //line 408左右添加
Then we add the following configuration in apache Under the root directory, the default is C:/Program Files/Apache Software Foundation/Apache2.2/htdocs. Create a new php file index.php. Edit and add the following code:
<?php phpinfo(); ?>
Then we enter http:// in the address bar. localhost/The following interface will appear: Pay attention to the relationship between the red part and the configuration
The above is the detailed content of How to run php source code in win. For more information, please follow other related articles on the PHP Chinese website!