Windows 10 Nginx + PHP

Posted on

NGINX can interface with PHP on Windows via a FastCGI daemon, which ships with PHP: php-cgi.exe. You need to run php-cgi.exe -b 127.0.0.1: and use fastcgi_pass 127.0.0.1:; in the NGINX configuration file. After being launched, php-cgi.exe will keep listening for connections in a command prompt window. To hide that window, use the tiny utility RunHiddenConsole



First

  • Download nginx, choose stable version.
  • Download PHP, choose non stable version.



Second

  • Extract nginx to “C:nginx”
  • Extract php to “C:php”
  • Create folder “www” in your “C” system , “C:www”



Third

  • Edit your nginx.conf at “C:nginxconfnginx.conf”
  • Change root

        root c:/www;
    
  • Save nginx.conf

  • Open yout php folder, find php-ini-development

  • Edit your php-ini-development, like down below.

        extension_dir = "ext" 
        enable_dl = On 
        cgi.force_redirect = 1 
        fastcgi.impersonate = 1 
        cgi.rfc2616_headers = 1 
        extension=php_gd2.dll 
        extension=php_mbstring.dll 
        extension=php_exif.dll 
        extension=php_mysql.dll 
        extension=php_mysqli.dll 
        extension=php_pdo_mysql.dll 
        date.timezone = "Asia/Jakarta" 
    
  • Save it.

  • Open your nginx.conf again

  • Uncoment on php configuration and change to this

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9999
        location ~ .php$ {
            fastcgi_pass   127.0.0.1:9999;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    
  • Save nginx.conf again.



Fourth

  • Set Php path
  • Open your environment variable
    • Open “edit the system environment variables”
    • Click, “Environtment variables …”
      Alt Text
    • Edit “path” on “Sytem ariables”
      Alt Text
    • Add new path “C:php”
      Alt Text



Create nginx start, stop & restart .bat

Leave a Reply

Your email address will not be published. Required fields are marked *