Install and configure PHP56 + Nginx18

Source: Internet
Author: User
: This article describes how to install and configure PHP56 + Nginx18. For more information about PHP tutorials, see. PHP

Download PHP 5.6 (VC11 x86 Non Thread Safe), decompress it to any Directory, copy the file php. ini-development, and rename it php. ini.

I have not modified the content of the php. ini file, and the tests later passed. If you want to change it later, you can refer to the http://php.net/manual/zh/install.windows.manual.php

Nginx

Download Nginx 1.80 and decompress any directory. Open the configuration file conf/nginx. conf and find the following section:

#location ~ \.php$ {##}

Delete all the preceding # Numbers and delete this line:

fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

Replace:

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

That is/scriptsReplace$document_root

The complete configuration block after modification is:

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {    root           html;    fastcgi_pass   127.0.0.1:9000;    fastcgi_index  index.php;    fastcgi_param  SCRIPT_FILENAME$document_root$fastcgi_script_name;    include        fastcgi_params;}

Or change the whole block to the following:

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {    root           html;    fastcgi_pass   127.0.0.1:9000;    fastcgi_index  index.php;    include        fastcgi.conf;}

Run

Then, create the info. php file in the Nginx Root directory (html directory). The content is as follows:


  

Start Nginx (if it has been started, turn off the restart ).

Start php-cgi (listening to Port 9000 of the local machine ):

cd path-to-php-homephp-cgi-b127.0.0.1:9000

If an error is reported, you need to first install the VC2012 (VC11) runtime library: http://www.microsoft.com/en-us/download/details.aspx? Id = 30679

Open the browser access address http: // 127.0.0.1/info. php

Nginx first receives the request and forwards it to php-cgi. The latter parses and executes the PHP code, returns it to Nginx, and finally returns it to the browser.

If the link can be opened normally and many PHP-related information (as shown in) is displayed, the configuration is successful.

This is the first time that I (Liigo) displayed this interface. it still feels quite comfortable.

PHP-FPM or spawn-fcgi or php-cgi?

Look at online analysis, PHP-FPM is much better than spawn-fcgi, and the PHP-FPM has been integrated by PHP 5.3.3 + official, so first elimination of spawn-fcgi, preferred PHP-FPM.

However, but to enable PHP-FPM, you have to compile the PHP source code yourself,./configure --enable-fpm .... This task is still very troublesome in the Windows environment and is temporarily abandoned.

What should we do? I didn't know what to do at the beginning. Later, I found out through network search that the original php-cgi program can also be used as a FastCGI server. So I chose php-cgi.

Conclusion: php-cgi can be used in the development environment for the time being. in the future, the deployment environment must be PHP-FPM.

PHP 5 or PHP 7?

PHP 7 is very powerful, but it has not yet been officially released. it also takes time to support various frameworks and codes. So for the time being, use PHP 5 honestly. Otherwise, new users will be helpless in the face of subtle compatibility issues.

Copyright Disclaimer: This article is an original article of the blogger and cannot be reproduced without authorization from the blogger.

The above introduces the installation and configuration of PHP 56 + Nginx 18, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.

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.