0

I'm trying to reach my index.php file on localhost / other-40.umwelt-campus.de but instead of calling the page it's downloading an empty file.. Even if I downloaded php fpm and configured it.

The file is at: /var/www/html/MyDigitalHome/index.php

Parts of the config file look like:

root /var/www/html/;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html index.php;

server_name _;

location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ /index.php$is_args$args;
        # proxy_pass http://localhost:8080;
        # proxy_http_version 1.1;
        # proxy_set_header Upgrade $http_upgrade;
        # proxy_set_header Connection 'upgrade';
        # proxy_set_header Host $host;
        # proxy_cache_bypass $http_upgrade;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
       include snippets/fastcgi-php.conf;

       # With php7.3-cgi alone:
       #fastcgi_pass 127.0.0.1:9000;

       # With php7.3-fpm:
       fastcgi_pass unix:/run/php/php7.3-fpm.sock;

}

The php file just looks like:

<!-- Redirect to MyDigitalHome mainpage-->
<?php
  header('Location: /MyDigitalHome/src/services/overview.php');
  exit;
Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
temp
  • 519
  • 7
  • 18

1 Answers1

1

Your redirection is broken. You must redirect over HTTP, but instead you point to local file, which means it is a) available only to people having access to that file system (usually just you), b) being accessed by web browser directly so no matter how good your nginx config is it will not matter as server is not involved in file access (it can be even down and you will get that file if you have filesystem access).

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
  • How would I do that? Just add "http://other-40.umwelt-campus.de/MyDigitalHome/src/services/overview.php" ? – temp Jun 03 '19 at 10:24
  • you cannot add some random chars and expect it to work. The file must be available for web server, so within configured document root. – Marcin Orlowski Jun 03 '19 at 10:49
  • so you must put that file i.e. next to currently served files (say copy into `/var/www/html/MyDigitalHome/` and then redirect to just `overview.php` (or services/overview.php if you want to copy whoile tree) – Marcin Orlowski Jun 03 '19 at 10:51
  • The file is at /src/services/overview.php . So I guess that'd be the right path then. – temp Jun 03 '19 at 11:03