I've setup nginx configuration to run php with fcgi on Windows. Here is my config:
server {
charset utf-8;
client_max_body_size 128M;
listen 8888;
server_name api.domain.local;
root /projects/domain.server.new/app/rest/web;
index index.php;
error_log /webservers/nginx/logs/api.domain.local.error.log;
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php?$args;
}
#uncomment to avoid processing of calls to non-existing static files by Yii
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
error_page 404 /404.html;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9123;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ //.(ht|svn|git) {
deny all;
}
}
I've checked if fcgi server is running and it's all OK:
E:\Webservers\Nginx>netstat -aon | findstr :9123
TCP 127.0.0.1:9123 0.0.0.0:0 LISTENING 2644
Then I request the file using curl
to prevent file caching:
$ curl -i localhost:8888
HTTP/1.1 200 OK
Server: nginx/1.6.1
Date: Sun, 08 Nov 2015 09:15:20 GMT
Content-Type: application/octet-stream
Content-Length: 960
Last-Modified: Tue, 27 Oct 2015 17:33:50 GMT
Connection: keep-alive
ETag: "562fb57e-3c0"
Accept-Ranges: bytes
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require(__DIR__ . '/../../common/config/bootstrap.php');
require(__DIR__ . '/../config/bootstrap.php');
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../common/config/main.php'),
require(__DIR__ . '/../../common/config/main-local.php'),
require(__DIR__ . '/../config/main.php'),
require(__DIR__ . '/../config/main-local.php')
);
$application = new yii\web\Application($config);
$application->run();
And it outputs files content instead of running it. I've tried several solutions offered in other topics:
- Changed
default_type application/octet-stream
todefault_type text/html
in the config - Changed
location ~ / .php$
tolocation ~* / .php$
But it doesn't work. How can I debug it?