Find by Category

Configure PHP with NGINX on Windows 10

This post will help configure php and NGINX on Windows 10 Desktop. I assume that you already have installed PHP and NGINX on your Windows system, if you have installed php and NGINX yet, you can follow my video instructions below to install PHP 7 and NGINX on Windows 10.

Install PHP 7

Make sure PHP is installed and configured properly on Windows 10. Now lets go ahead and install NGINX and configure it for PHP on Windows 10.

Install NGINX

Now, I assure that you have PHP and NGINX installed. PHP is setup and NGINX is running on your system. Let’s configure NGINX with PHP.

Configure NGINX with PHP 7

Open nginx.conf under nginx/conf/nginx.conf file and make following changes in the file and save it.

On nginx.conf > add index.php to index

# add index.php to index
 location / {
            root   html;
            index  index.php index.html index.htm;
        }

Under nginx.conf > uncomment the following lines of code and replace /script with $document_root$fastcgi_script_name

# Replace with $document_root$fastcgi_script_name  
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;
        }

Change Directory to PHP and run the following command and keep it running

Keep it running
C:\tools\php74>php-cgi.exe -b 127.0.0.1:9000

Download PHP 7 eBook For Free

Test phpinfo() with NGINX

Now you can create a folder in your root directory /html/ and then create a .php file or create a .php file directly in /html/ to test if .php files are read by the NGINX server.

phpinfo() test with NGINX server

I have created phpinfo.php and hello/index.php and in both files and echoing phpinfo method.. and it’s rendering the desired page.

Still can’t configure PHP and NGINX then watch me configure php and NGINX on Windwos 10

Related Posts..

  1. Install PHP, MySQL and Apache on Windows 10
  2. Install WordPress on Windows 10
  3. Install Drupal on Windows 10
  4. Install Joomla on Windows 10