Window +nginx+ PHP environment configuration

  • 2020-03-31 21:22:23
  • OfStack

1. Download PHP
There are many downloaded versions of PHP, among which,
Vc9 =vs2008, IIS+ PHP collocation mode is recommended.
Vc6 =vs6 compilation, recommended to use apache+ PHP mode with,
Thread Safe, thread-safe, executes with a Thread security check to prevent system resources from being exhausted by new requirements for starting a new Thread's CGI execution. Non Thread Safe is non-thread-safe and does not perform Thread security checks at execution time.
Non Thread Safe,
Let's take a look at two implementations of PHP: ISAPI and FastCGI.
The execution method of ISAPI is in the form of DLL dynamic library, which can be executed after being requested by the user, and will not disappear immediately after a user request is processed. Therefore, Thread safety check is needed to improve the execution efficiency of the program. Therefore, if PHP is executed by ISAPI, it is recommended to select Thread Safe version.
The FastCGI execution method is a single Thread to perform operations, so there is no need for Thread security check, and the protection of Thread safety check can improve the execution efficiency instead. Therefore, if FastCGI is used to execute PHP, it is recommended to choose the non-thread Safe version.
It is not officially recommended that you use Non Thread Safe in a production environment, so we will use the Thread Safe version of PHP instead.
2. Configure PHP
Unzip to a directory, such as c:/php345
Rename php.ini-development to php.ini
Fastcgi.impersonate =1 defaults to 0. If you use IIS, you will need to enable: cgi.fix_pathinfo=1
Cgi. Force_redirect =0 is enabled by default and can be turned off if you use IIS
Next, specify the extension_dir directory and the date.timezone directory
Extension_dir = "C: / php53iis/ext"
The date. The timezone = Asia/Shanghai
If you modify the cgi. Fix_pathinfo = 1 in the php.ini configuration file, PHP will fix the SCRIPT_FILENAME to the real file address, otherwise PHP will not be able to find the PHP file that needs to be processed.
3. Configure nginx
Unzip nginx, such as c:/nginx

Set the storage directory of error.log, and set #error_log /error.log; The default error.log is stored in the Nginx installation directory under the logs directory.

Set up the WEB server directory, similar to the document_root in the php.ini configuration file. The information in the Nginx configuration file is as follows
 
location / { 
root D:/PHPWeb; 
index index.php index.html index.htm; 
} 

 
location ~ .php$ { 
root D:/PHPWeb; 
fastcgi_pass 127.0.0.1:9000; 
fastcgi_index index.php; 
fastcgi_param SCRIPT_FILENAME D:/PHPWeb$fastcgi_script_name; 
include fastcgi_params; 

Note: the /scripts in fastcgi_param SCRIPT_FILENAME are changed to the previously set WEB directory, otherwise an HTTP 404 error will be reported.

If you modify the cgi. Fix_pathinfo = 1 in the php.ini configuration file, PHP will fix the SCRIPT_FILENAME to the real file address, otherwise PHP will not be able to find the PHP file that needs to be processed.
4. Run
Download RunHiddenConsole
Firewall support RunHiddenConsole C:/php52iis/ php-cgi.exe-b 127.0.0.1: 9000-c C:/ Windows /php.ini

From: http://www.cnblogs.com/ihwt/archive/2010/12/18/1909742.html

If you want to save more trouble, you can use the following software to quickly deploy nginx-based PHP runtime environment:
(link: #)

Related articles: