OPessoa Blog


Posted on 2017-05-12 13:14:59

Running NGINX with PHP on Windows.
Hi all folks!

After 2 or 3 years using apache to run my php app's, in development, on Windows I have decided to use only PHP Built-in Server.

Ok, perfect to execute personal tests. But, with only 2 testers, my Built-in Server does not stand. After some searchs and tests we have found the `problem`. PHP built-in server only accepts one request per time. Yes, I know, this seems some obvious. 

So, ok, because this is not a problem. Well, lets use than some server like apache, nginx... 

I choose NGINX because I like to learn some news things...

Downloaded NGINX - http://nginx.org/.


Downloaded PHP lastes windows 64 thread safe version - http://windows.php.net/download/.


Reading some texts I've found this config for NGINX:

worker_processes  1;
events {
worker_connections  1024;
http {
server {
listen 80 default;
root   /site;
index  index.php index.html;

location = /robots.txt {access_log off; log_not_found off;}
location ~ /\\. {deny all; access_log off; log_not_found off;}
location / {
try_files $uri $uri/ /index.php?$args;
# Route all requests for PHP files to PHP-fastcgi
location ~ \.php($|/) {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

Just reading this, I think: "Damn I will get same `problem`, because this is running fastcgi at".

I found one 'ugly' deviation for this... Batch command :P!

php\php-cgi.exe -b -c php\php.ini

Now, I have 5 ugly proccess running on my Windows, but solve, the only one request problem! 

This is my firts NGINX experience!

"Just remember unlike Nginx each PHP process can only handle one request at a time, so limiting to a single process is not advised."