Step by step PHP (1): configure the Nginx + PHP development environment in Windows

Source: Internet
Author: User
Tags php development environment vc9
Step by step to learn PHP (1): Configure Nginx + PHP development environment under Windows 1, download and install nginx1.1: http://nginx.org/en/download.html       &nbsp step by step to learn PHP (1): Configure Nginx + PHP development environment under Windows
1. download and install nginx
  • 1.1: http://nginx.org/en/download.html
  • Http://nginx.org/download/nginx-1.3.0.zip
  • 1.2 unzip the nginx-1.3.0.zip to G: \ webserver
  • 1.3 to G: \ webserver rename the nginx-1.3.0 folder to nginx

  • 2. start nginx and test the normal operation of nginx.
  • 2.1 to G: \ webserver \ nginxexecute nginx.exe. the nginx.exe process exists in the task manager.
  • 2.2 enter http: // 127.0.0.1 in the browser and you will see "Welcome to nginx! "Indicates that nginx is running normally.

  • 3. understand the differences between VC9, VC6, Thread Safe, and Non-Thread Safe in PHP.
  • Differences between 3.1 VC9 and VC6
  • VC6 is compiled using the Visual Studio 6 compiler. if your PHP is set up using Apache, select VC6.

    VC9 is compiled using the Visual Studio 9 (2008) compiler. if your PHP is set up using IIS, select VC9.
  • 3.2 Differences between Thread Safe and Non-Thread Safe
  • First, it is literally understood that Thread Safe is Thread security, and Thread security check is performed during execution, to prevent the new thread from consuming system resources by starting the CGI execution mode. Non-Thread Safe is Non-Thread security and does not perform Thread security checks during execution.

    Let's take a look at two PHP execution methods: ISAPI and FastCGI.

    The ISAPI is executed in the form of a DLL dynamic library. it can be executed after a user request. after processing a user request, it will not disappear immediately. Therefore, thread security check is required, in this way, the program execution efficiency is improved. if you use ISAPI to execute PHP, we recommend that you select the Thread Safe version;

    FastCGI executes operations in a single thread, so it does not need to perform thread security checks. apart from the thread security check protection, it can improve the execution efficiency, if you use FastCGI to execute PHP, we recommend that you select the Non-Thread Safe version.

    4. download and install php
  • 4.1: http://windows.php.net/download
  • Http://windows.php.net/downloads/releases/php-5.4.3-nts-Win32-VC9-x86.zip
  • 4.2 to G: \ webserver
  • 4.3 decompress php-5.4.3-nts-win32-vc9-x86.zip to the G: \ webserver \ php Directory

  • 5. create the source file directory
  • 5.1 copy the html directory under the nginx directory to the G: \ webserver \ directory and rename it as webroot

  • 6. configure and start nginx
  • 6.1 modify G: \ webserver \ nginx \ conf \ nginx. conf. The difference is as follows:
  • [root@localhost test]# diff nginx.conf nginx.conf.default 44,45c44,45<             root   G:/webserver/webroot;<             index  index.html index.htm index.php;--->             root   html;>             index  index.html index.htm;65,70c65,71<         location ~ \.php$ {<             fastcgi_pass   127.0.0.1:9000;<             fastcgi_index  index.php;<             fastcgi_param  SCRIPT_FILENAME  G:/webserver/webroot$fastcgi_script_name;<             include        fastcgi_params;<         }--->         #location ~ \.php$ {>         #    root           html;>         #    fastcgi_pass   127.0.0.1:9000;>         #    fastcgi_index  index.php;>         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;>         #    include        fastcgi_params;>         #}[root@localhost test]# 
  • 6.2 in the command line status, run nginx.exe-t in the G: \ webserver \ nginxdirectory to test whether the configuration file is correct.
  • 6.3 run nginx.exe in the G: \ webserver \ nginxdirectory to start nginx
  • 6.4 In the command line status, run nginx.exe-s stop in the G: \ webserver \ nginxdirectory to stop nginx and nginx. ex-s reload to re-load the configuration.

  • 7. configure and start php
  • 7.1 to the G: \ webserver \ php Directory. to save the original configuration file, copy php. ini-development to php. ini. default.
  • 7.2 rename php. ini-development to php. ini (there are two identical configuration files: php. ini and php. ini. default)
  • 7.3 open php. ini, search for short_open_tag = Off, and change it to search for short_open_tag = On.
  • 7.4 to enable common extensions and set the default time zone to Chongqing, add the following content at the end of the file:
  • extension_dir = "G:\webserver\php\ext"extension=php_curl.dll extension=php_gd2.dll extension=php_mbstring.dll extension=php_mysql.dll extension=php_mysqli.dll extension=php_pdo_mysql.dll extension=php_pdo_sqlite.dll extension=php_sockets.dll extension=php_sqlite.dll extension=php_sqlite3.dll extension=php_exif.dll date.timezone = Asia/Chongqing
  • 7.5 compared with the unmodified configuration file php. ini. default, the differences are as follows:
  • [root@localhost test]# diff php.ini php.ini.default 211c211< short_open_tag = On---> short_open_tag = Off1860,1874d1859< < extension_dir = "G:\webserver\php\ext"< extension=php_curl.dll < extension=php_gd2.dll < extension=php_mbstring.dll < extension=php_mysql.dll < extension=php_mysqli.dll < extension=php_pdo_mysql.dll < extension=php_pdo_sqlite.dll < extension=php_sockets.dll < extension=php_sqlite.dll < extension=php_sqlite3.dll < extension=php_exif.dll < date.timezone = Asia/Chongqing< [root@localhost test]# 
  • 7.6 start php: G: \ webserver \ php \ php-cgi.exe-B 127.0.0.1: 9000-c G: \ webserver \ php. ini


  • 8. php development environment configuration is successfully tested.
  • 8.1 create phpinfo. php in the webroot directory and save the following content:
  • phpinfo
     
      Welcome to php
     
     
  • 8.2 enter http: // 127.0.0.1/phpinfo. php in the browser to view the "Welcome to php" and phpinfo information, indicating that the php configuration is successful.

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