# Windows and nginx and php, relative html folder outside nginx folder not working?

**URL:** <https://community.nginx.org/t/windows-and-nginx-and-php-relative-html-folder-outside-nginx-folder-not-working/11218>\
**Category:** General Discussion\
**Tags:** config\
**Created:** [October 5, 2026, 2:51pm UTC](https://community.nginx.org/t/windows-and-nginx-and-php-relative-html-folder-outside-nginx-folder-not-working/11218 "2026-10-05T14:51:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joeyq](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@joeyq](https://community.nginx.org/u/joeyq)\
**Post date:** [October 5, 2026, 2:51pm UTC](https://community.nginx.org/t/windows-and-nginx-and-php-relative-html-folder-outside-nginx-folder-not-working/11218/1 "2026-10-05T14:51:52Z")

</div>

I want to setup a portable nginx server and later put it on a usb stick  
I’m new to nginx and asked google gemini ai “windows portable nginx with php, how to install and setup”.

portable-server/  
├── html/ ← Your website/code files (document root)  
├── nginx/ ← Extract Nginx zip here  
├── php/ ← Extract PHP zip here  
├── start.bat ← Batch file to start the server  
└── stop.bat ← Batch file to stop the server  
nginx.conf in “C:\portable-server\nginx\conf”:

```auto
worker_processes 1;
events {
    worker_connections 1024;
}
http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;
    server {
        listen 80;
        server_name localhost;
        root ../html;
        index index.php index.html index.htm;
        location / {
            try_files $uri $uri/ =404;
        }
        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;
        }
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }
    }
}

```

html files work, php not (probably somehow root ../html; not working). how do I make it work with php files?

---

<div class="post-metadata">

**Author:** ![FrancisD](https://avatars.discourse-cdn.com/v4/letter/f/ea5d25/32.png) [@FrancisD](https://community.nginx.org/u/FrancisD)\
**Post date:** [October 8, 2026, 2:53pm UTC](https://community.nginx.org/t/windows-and-nginx-and-php-relative-html-folder-outside-nginx-folder-not-working/11218/2 "2026-10-08T14:53:25Z")

</div>

Hi there,

I do not have a Windows system here to test against, so this is “some suggestions to try” rather than “a recipe known to work”.

[nginx for Windows](https://nginx.org/en/docs/windows.html) indicates that paths within nginx.conf are relative to the directory where it has been run; which is presumably why the “root ../html;” part allows “normal” files to be served successfully – it is being run from within the “nginx” directory, and so a request for /one.html returns the content of ../html/one.html, relative to  
the directory nginx/.

nginx itself does not “do” php. What it does, is it presents some strings to the fastcgi service, and it expects that _that_ service will Do The Right Thing with those strings to identify which php file to read.

Typically the php-fastcgi process will expect either SCRIPT\_FILENAME as the name of the file to read; or the concatenation of DOCUMENT\_ROOT and SCRIPT\_NAME as the name of the file to read.

(In general, the php process can run on a remote machine; or can run on the local machine but in a chroot environment so that the name that process uses to identify a file may not be the same as one that nginx would use.)

So – in your case, when a request is made for /two.php, what file on your filesystem do you want your php fastcgi service to read? (Maybe it is “C:\portable-server\html\two.php”, or “C:\portable-server\php\two.php”?)

And what name will your php fastcgi service use to identify that file? (Maybe it can be “html/two.php”, or “../html/two.php”; or maybe it must be the full “C:/portable-server/html/two.php”?) The manual for your php fastcgi service will hopefully say what form of relative path it accepts, if it accepts any.

Once you know the request-to-filename mapping that you want; and you know which parameter(s) your php fastcgi service will read; it should be more obvious how to apply the mapping.

nginx logging can show what parameter names and values it is writing; hopefully the php fastcgi server logging can show what it is reading and how it is interpreting them. You can also temporarily add something like

```
return 200 "name would be $document_root$fastcgi_script_name\n";

```

to the matching location{} to see if that output matches what you want it to.

Good luck with it!
