Install Nginx Windows Php-Fpm

Install Nginx Windows Php-Fpm

Nginx is a web server that is known for its high performance and low resource usage. It is commonly used to serve static content, reverse proxy to other web servers or even as a load balancer. Php-fpm (FastCGI Process Manager) is an alternative FastCGI implementation for PHP, which stands for Hypertext Preprocessor, a server-side scripting language designed primarily for web development.

In this article, we will discuss how to install Nginx, Php-fpm, and configure them on a Windows environment.

1. Installing Nginx on Windows

Firstly, go to the Nginx download page, select the latest stable version and click on the link for the Windows version. Download the 32-bit or 64-bit executable file and save it on your computer.

Next, extract the zip file to a folder on your computer, for example, C:nginx. Once that is done, we can start configuring Nginx.

2. Configuring Nginx

Nginx’s configuration file is located in the conf folder inside the Nginx installation folder. Open the nginx.conf file in a text editor, and you will find a configuration block similar to this:

“`
http {
include mime.types;
default_type application/octet-stream;

sendfile on;
# etc…
}
“`

We will add some more configurations to make Nginx work with Php-fpm. But before that, we need to install Php-fpm first.

3. Installing Php-fpm on Windows

Go to the PHP download page, select the latest version and click on the link for the “VC15 x64 Non Thread Safe” version. Download the zip file and extract it to a folder on your computer, for example, C:php. Once that is done, we can continue configuring Nginx.

4. Configuring Php-fpm

Php-fpm has a configuration file named php.ini located in the PHP installation folder. Open the file in a text editor and make some changes to the file.

Add the following lines under the Dynamic Extensions section to enable the required extensions:

“`
extension=php_curl.dll

extension=php_mbstring.dll

extension=php_mysqli.dll

extension=php_openssl.dll
“`

Next, scroll down to the end of the file, and add the following lines to enable Php-fpm:

“`
[PHP]
cgi.force_redirect = 0

cgi.fix_pathinfo=1

fastcgi.impersonate = 1
“`

5. Configuring Nginx and Php-fpm Together

Open the Nginx configuration file in a text editor and add the following lines:

“`
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
“`

This configuration tells Nginx to pass all requests that end with “.php” to Php-fpm. Once you save the changes to the Nginx configuration file, restart Nginx and Php-fpm.

6. Conclusion

In conclusion, installing and configuring Nginx Windows Php-fpm might seem a bit complex, but it is relatively easy to do if you follow this guide. With this configuration, you can now serve PHP scripts with Nginx and Php-fpm on a Windows environment.

Please remember that this is only a basic configuration for Nginx and Php-fpm, and you can always tweak the configuration to suit your needs.