PHP and NGINX
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/.
And.
Downloaded PHP lastes windows 64 thread safe version - http://windows.php.net/download/.
Perfect!
Reading some texts I've found this config for NGINX:
worker_processes 1;events {worker_connections 1024;}http {
server {listen 80 default;server_name 127.0.0.1;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-fastcgilocation ~ \.php($|/) {include fastcgi_params;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_pass 127.0.0.1:9000;}}}
Just reading this, I think: "Damn I will get same `problem`, because this is running fastcgi at 127.0.0.1:9000".
I found one 'ugly' deviation for this... Batch command :P!
set PHP_FCGI_CHILDREN=5php\php-cgi.exe -b 127.0.0.1:9000 -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."