I have the following configuration added to nginx.conf:
server {
server_name domain.vhost;
root C:/WT-NMP/WWW/domain.vhost/web;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
# DEV
# This rule should only be placed on your development environment
# In production, don't include this and don't deploy app_dev.php or config.php
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include nginx.fastcgi.conf;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
# PROD
location ~ ^/app\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include nginx.fastcgi.conf;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/app.php/some-path
# Remove the internal directive to allow URIs like this
#internal;
}
error_log C:/WT-NMP/log/domain.vhost.error.log;
access_log C:/WT-NMP/log/domain.vhost.access.log;
}
The problem is that it doesn't work. It does on my Ubuntu server. It does not on my windows WT-NMP nginx local machine. There are no logs showing up, and the only URL I can access is:
domain.vhost/domain.vhost/web/app_dev.php/
, as when I enter domain.vhost/
I get the list of files on server to choose from.
What's wrong?
You copy/pasted directives from your linux server without understanding them. The WT-NMP server stack for Windows generates the Nginx config file when you create a new project. Start by creating a new project and carefully modifying it's configuration file conf\domains.d\myProject.conf
, with directives from your other machine..
WT-NMP: How to create a new Project
And since you seem to use a custom sub directory for public files, read
WT-NMP: How to change the root directory of a project
Also, the NGINX Documentation should help..
Tips: do not copy fastcgi_pass
or fastcgi_split_path_info
directives from your linux server