php windows IIS installation and configuration services
Start IIS service
- Open the "Control Panel" => "program" => "Enable or disable Window function":
- Then select the corresponding settings:
- Continue by selecting the corresponding directory CGI module (mounted to the use configuration php):
- At this point in the "C drive" will be more than a folder "inetpub", open look inside the directory structure
As shown above, the price of each file stored in different files, history, logs, etc., I do use the "wwwroot" folder, which has a html file is opened after a picture is displayed in the content server home page, browsing open the computer's IP address, you can visit this page of (do not know the ip address of words, win + R, type cmd to open the terminal, enter the command ipconfig to see the machine IP).
I have to replace the files inside:
In the browser opens:
- You can modify the permissions of a folder, so that each time you modify a file, when not prompted to deny access to information such as:
Select "wwwroot" folder => right click "Properties" => "Security" => "Advanced":
Select the corresponding "subject", click Edit, check the appropriate access rights to:
2. Install php
Download: https://windows.php.net/download
Select the appropriate version, here I downloaded the zip file, extract to the C drive "C: /php-7.1.21", after the extraction is completed into the folder, the file php.ini-development rename php.ini, by editor opens search:
; extension_dir = "./" 修改为 extension_dir = "c:/php-7.1.21/ext" ( 前面的分号去掉,引号内为安装php的路径);cgi.force_redirect = 1 修改为 cgi.force_redirect = 0 ( 去掉前面的分号,值修改为1 );cgi.fix_pathinfo = 1 修改为 cgi.fix_pathinfo = 1 ( 去掉前面的分号 );fastcgi.impersonate = 1 修改为 ;fastcgi_impersonate = 1 ( 去掉前面的分号 )
Save and exit.
In the search box search window IIS, enter the "IIS Manager" => Open "Handler Mappings" => "Add Module Mapping":
Modify as follows:
Then create a php file, saved in the "wwwroot" directory, open a browser to access:
<?php
echo "hello world!";
?>
Configuring the system environment variables
Environment variable configuration system is able to be able to execute php cmd command shell or other tool in any directory path, is arranged in the Path entry system variables plus a current path to the directory php. With Win10 example:
After saving is complete, reboot cmd to execute a php command in any directory path.
PHP configuration file settings
In the default PHP installation directory has the executable file php.ini-development and php.ini-production profiles of these two styles, which is the reference file, not the actual functioning of the configuration file, the main difference is that the two default settings the error handling in different ways. Here I choose php.ini-development copy in the same directory and renamed the php.ini, and then modify the content to be complete copy php.ini to the C: \ Windows \ directory, the configuration file to take effect.
Set the time zone
Disposed before the entry removed;, set a value of PRC
Open openssl, mbstring, crul, mysqli, pdo_mysql and other extensions
The default configuration file is closed, these extensions, the extension file is already on ext PHP installation directory under the directory, so just leave a comment here before you can use the line-related extensions.
Finally, the placement of the edited configuration file to the C: \ Windows \ directory to take effect.
Start playing
Turn on the built-in server
using the PHP built-in server we can easily develop the project up and running, and only takes a single command can be realized. The entire command is php -S localhost: 1023 -td: \ code \ lv56 \ public, after -S is connected to the server address and port, then the back entrance -t directory path of the project. -T which is optional, with no word on the default directory is the directory entry cmd command currently being executed. After opening can use ctrl + c key combination to terminate the server process.
Use interactive mode
When using the interactive mode without editing the file, execute code directly for simple code test scenarios. Execute the command line, php -a
you can enter the interactive mode. Note end of each line of code to add ;
, or will be treated as the bank statement is not over, but then an error or is not executed.