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;
4
  • Check the index and access logs. Perhaps your PHP script is generating empty content. You can use an index.php file with a single line <?php phpinfo(); to test your configuration. Commented Jun 3, 2019 at 9:58
  • @RichardSmith The index.php is showing the php information. So it should work... Commented Jun 3, 2019 at 10:05
  • Your PHP file seems to work fine. Commented Jun 3, 2019 at 10:20
  • @RichardSmith There is no "php_errors.log" even if the php.ini is configured so. Also not commented out. So what could the problem be? Commented Jun 3, 2019 at 10:22

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

4 Comments

you cannot add some random chars and expect it to work. The file must be available for web server, so within configured document root.
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)
The file is at /src/services/overview.php . So I guess that'd be the right path then.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.