Installation configuration PHP + Nginx 18

Source: Internet
Author: User
Tags configuration php php source code
Php

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

I did not modify the contents of the php.ini file, and the following test passed. If you want to change later, you can refer to http://php.net/manual/zh/install.windows.manual.php

Nginx

Download Nginx 1.80, unzip any directory. Open its configuration file conf/nginx.conf find the following paragraph:

#location ~ \.php$ {##}

Delete the previous # and put it in the line:

fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

To be replaced by:

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

That /scripts is to replace the$document_root

The complete configuration block after the 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 you can 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) with the following contents:


    
     phpinfo();

Start Nginx (if it is already started, turn off the reboot).

Start php-cgi (listen for native 9000 ports):

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

If an error occurs, you need to 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 then forwards it to php-cgi, which parses the PHP code and returns it to Nginx, eventually returning it to the browser.

If you open the link normally and display a lot of information about PHP (as shown), the configuration is successful.

This is the first time I (Liigo) to show this interface, it is quite comfortable.

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

Look on-line analysis, php-fpm than spawn-fcgi better, and PHP-FPM has been 5.3.3+ the official integration of PHP, so first eliminated spawn-fcgi, preferred php-fpm.

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

And then what? I didn't know what to do at the beginning. Later through the network search only know the original php-cgi program can also do FastCGI server. Then retreat and beg second, choose php-cgi.

conclusion, the development environment can be temporarily used php-cgi, the future deployment environment must also be php-fpm.

PHP 5 or PHP 7?

PHP 7 is very good and powerful, but has not yet been formally released, and frameworks and code support it also require transition time. So temporarily or honestly use PHP 5, or novice face subtle compatibility problems will inevitably be helpless.

Copyright NOTICE: This article for Bo Master original article, without Bo Master authorized not reproduced.

The above describes the installation configuration PHP + Nginx 18, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • 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.